不要追求绝对的公平,红尘之中没有公平而言,人活一世,难得糊涂。                                           it is no use doing what you like, you have got to like what you do.

QTP HTML Report Functions

上一篇 / 下一篇  2009-06-10 15:04:04 / 个人分类:自动化测试

每日随笔
  • 每日随笔:
' Variables
CdH7C4md ux1h:Zr051Testing软件测试网ABq4TB6N+c
Dim fso, ts51Testing软件测试网bo O3b"oR
dim intCnt51Testing软件测试网l\ Lz#Ph/K`'@
Const ForWriting = 251Testing软件测试网sRa m1u}j
dim intPass,intFail
!b_g9\ },K9I9[8u0dim StartTime51Testing软件测试网c d5VLosW.g
dim stTime51Testing软件测试网7R:Y O)[ | ~.s2F4a
dim enTime51Testing软件测试网)Y6s-g+O,A
dim objIE
6tto|4u0dim strFileURL
4B5c5w#f1B5C-{QOx3E051Testing软件测试网K t6h[I
'Implementation
P(I*qH:\^^0i0OpenFile "C:\Test.html"51Testing软件测试网4^%|Z+}4L1m6}&K
AddNewCase 1,"X","X","X","Pass"51Testing软件测试网5W7^g A]
AddNewCase 2,"X","X","X","Fail"
-h:~.KT w Q0AddNewCase 3,"X","X","X","Pass"
*R+U!W3}3B%t _"i&x0CloseFile51Testing软件测试网Lx+d.U`#jY5T

-|u;tCj_0' Function To Open the HTML file
'sbNS)H1@C&C6t gNs051Testing软件测试网 lv` j ]'T
Function OpenFile(strFileName)
^2PUf:ZgQ(K#j0StartTime = Timer
0Xx4{e3R@;d[q%KZ0stTime = Time
,X3h9{C ECb0Set fso = CreateObject("Scripting.FileSystemObject")51Testing软件测试网$^'P(q!M*I:T@)i
Set ts = fso.OpenTextFile(strFileName, ForWriting, True)
,]m(}ZS V0strFileURL = strFileName
W&d3\PvE"d:L io0CreateHeader51Testing软件测试网+YB qF2d a6L/_@j
End Function
K*G;{$c3z0y051Testing软件测试网)v2BFk!h/I+~#}
' Function To Create Header51Testing软件测试网!a-u:t}yht

R'm]-Td A T+FY6w0Function CreateHeader()
RCfq]jf0ts.writeline("<html>")51Testing软件测试网5iCeR K6{
ts.writeline("<title>Test Results</title>")
\@p b!n0ts.WriteLine("<head></head>")
3n*MU$W&g,y0ts.WriteLine("<body>")
D `[1v Z,|s0ts.WriteLine("<font face='Tahoma'size='2'>")51Testing软件测试网u"b6k.v6j?b%`:v
ts.WriteLine("<h1>Test Results</h1>")51Testing软件测试网@+dY\j/d
ts.writeline("<table border='0' width='100%' height='47'>")51Testing软件测试网ds"P6}A*]:pP
ts.writeline("<tr>")51Testing软件测试网K"U+q%Zp\K6@Q:Z!u
ts.writeline("<td width='13%' bgcolor='#CCCCFF' align='center'><b><font color='#000000' face='Tahoma' size='2'>TestCaseID</font></b></td>")51Testing软件测试网-Q(c`,{6Y1Xc
ts.writeline("<td width='24%' bgcolor='#CCCCFF'><b><font color='#000000' face='Tahoma' size='2'>Objective</font></b></td>")51Testing软件测试网b |KyjGK6K
ts.writeline("<td width='23%' bgcolor='#CCCCFF'><b><font color='#000000' face='Tahoma' size='2'>Expected Result</font></b></td>")
f:lf'uH.yO0ts.writeline("<td width='22%' bgcolor='#CCCCFF'><b><font color='#000000' face='Tahoma' size='2'>Actual Result</font></b></td>")51Testing软件测试网| Ye8v/N7rzn
ts.writeline("<td width='18%' bgcolor='#CCCCFF' align='center'><b><font color='#000000' face='Tahoma' size='2'>Pass/Fail</font></b></td>")
*t H4r{|0zh0ts.writeline("</tr>")
5X6c&X O*J T+z0End Function
9`:E4TVHY i-m6r"u#m051Testing软件测试网k6|7}O@0Qm
' Function To Add New Case51Testing软件测试网@)_8P[7AD

C,lU d%z9ug0Function AddNewCase(strTCID,strObjective,strExpectedResult,strActualResult,strPassFail)51Testing软件测试网 s:A:f'Wx
ts.writeline("<tr>")51Testing软件测试网2G+\Mn-a.t
ts.writeline("<td width='13%' bgcolor='#FFFFDC' valign='middle' align='center'>" & strTCID & "</td>")
zc3a"TAw*DQ4~X a0ts.writeline("<td width='24%' bgcolor='#FFFFDC' valign='top' align='justify'>" & strObjective & "</td>")
hT _ c qe+T'xe0ts.writeline("<td width='23%' bgcolor='#FFFFDC' valign='top' align='justify'>" & strExpectedResult & "</td>")
a C^3K yMM2g0ts.writeline("<td width='22%' bgcolor='#FFFFDC' valign='top' align='justify'>" & strActualResult & "</td>")
|SK7D_0if strPassFail = "Pass" then51Testing软件测试网*UxV-J@4[cc
ts.writeline("<td width='18%' bgcolor='#FFFFDC' valign='middle' align='center'><b><font color='Green' face='Tahoma' size='2'>" & strPassFail & "</font></b></td>")
z"CM c C'V0intPass = intPass + 1
M] r8v0zvW p_ Kx0else51Testing软件测试网.Y+@l ?;i*aJ?pMc
ts.writeline("<td width='18%' bgcolor='#FFFFDC' valign='middle' align='center'><b><font color='Red'
D b-{q'h!@O7^0face='Tahoma' size='2'>" & strPassFail & "</font></b></td>")
]/XP_8b0intFail = intFail + 151Testing软件测试网+nsw!rB
end if51Testing软件测试网`zc"z,o t*k4N
ts.writeline("</tr>")
C8} ^6eF v2\0End Function51Testing软件测试网+iJ8j M0KdXQ*d

7{'u N3UWH:w;a0' Function To Footer Info51Testing软件测试网 N(q `$\ s!Jw
51Testing软件测试网:T%uU rD
Function Footer()51Testing软件测试网 x^:Kcet
Dim EndTime
k~5Wc-a+uP0EndTime = Timer51Testing软件测试网x\1T`:Q
enTime = Time51Testing软件测试网o0YCY9`U9lf
ts.writeline("</table>")51Testing软件测试网B0p6h,QsJ2m
ts.writeline("<hr>")51Testing软件测试网(qFZC$K"O|o8E
ts.writeline("<table border='0' width='50%'>")
h,G L#k'n%j4a'G0ts.writeline("<tr><td width='100%' colspan='2' bgcolor='#000000'><b><font face='Tahoma' size='2' color='#FFFFFF'>Summary</font></b></td></tr>")
R2WQ(kY7};d] b0ts.writeline("<tr><td width='45%' bgcolor='#E8FFE8'><b><font face='Tahoma' size='2'>Total Tests Passed</font></b></td><td width='55%' bgcolor='#E8FFE8'>" & intPass & "</td></tr>")
#? AQK"R#D0]0ts.writeline("<tr><td width='45%' bgcolor='#FFE6FF'><b><font face='Tahoma' size='2'>Total Tests Failed</font></b></td><td width='55%' bgcolor='#FFE6FF'>" & intFail & "</td></tr>")
rxP}"Z,L6y:A Z0ts.writeline("<tr><td width='45%' bgcolor='#FFFFDC'><b><font face='Tahoma' size='2'>Executed On</font></b></td><td width='55%' bgcolor= '#FFFFDC'>" & Date & "</td></tr>")51Testing软件测试网{T*DP6b}H&k LoY
ts.writeline("<tr><td width='45%' bgcolor='#FFFFDC'><b><font face='Tahoma' size='2'>Start Time</font></b></td><td width='55%' bgcolor= '#FFFFDC'>" & stTime & "</td></tr>")
\,G,hq9KuS0ts.writeline("<tr><td width='45%' bgcolor='#FFFFDC'><b><font face='Tahoma' size='2'>End Time</font></b></td><td width='55%' bgcolor= '#FFFFDC'>" & enTime & "</td></tr>")
~X1x3u:sfS_0ts.writeline("<tr><td width='45%' bgcolor='#FFFFDC'><b><font face='Tahoma' size='2'>Execution Time</font></b></td><td width='55%' bgcolor= '#FFFFDC'>" & CDbl(EndTime - StartTime) & "</td></tr>")
`l+P UjcV _&M0ts.writeline("</table>")51Testing软件测试网`TM%oL
ts.writeline("</font>")51Testing软件测试网c5`/O&eV{2Zd
ts.WriteLine("</body>")51Testing软件测试网$D5X9RY G0F b
ts.WriteLine("</html>")
tR KjZ0H)w0End Function
'nm*D&v q*U,J051Testing软件测试网%NH2Ejqj;K"?x
' Function To Close File
dG.}%G L ?+NY|)?w051Testing软件测试网P7i U,s K+j4R
Function CloseFile()
Ee }bz)V0Footer
2g.Z$w-Vk0ts.close()
1oon;aA7R8S*p-Kd0Set bjIE = CreateObject("InternetExplorer.Application")51Testing软件测试网2f|on0H1IcY-g
objIE.visible = True
u$d|?!K2fp{)LL0objIE.Navigate strFileURL51Testing软件测试网F c?h!F,e|
End Function

TAG: HTML QTP Report Functions

琛杰的个人空间 引用 删除 琛杰   /   2010-04-14 12:27:41
 

评分:0

我来说两句

Open Toolbar