不要追求绝对的公平,红尘之中没有公平而言,人活一世,难得糊涂。                                           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
1@A\&S+eO7n051Testing软件测试网mls~V$x
Dim fso, ts
g r#C.O"b*Q/Y Oy0dim intCnt
6I:X3^@/y5Q:`C0Const ForWriting = 251Testing软件测试网m {[LK
dim intPass,intFail
pWkq6d`0dim StartTime
ueU0^p0dim stTime
0^a&D+wQO Z0dim enTime51Testing软件测试网Go;LB:v
dim objIE
O(ycg D/Z"g"e0dim strFileURL51Testing软件测试网4g1MN1p fman

MM Q3d%@*l:@^ ?I x0'Implementation
1z)S7xQ]Xj0OpenFile "C:\Test.html"51Testing软件测试网hFcQL ^
AddNewCase 1,"X","X","X","Pass"
8D$n M'a-Y^0AddNewCase 2,"X","X","X","Fail"51Testing软件测试网:cR'{!lzW6RMg(m
AddNewCase 3,"X","X","X","Pass"
'B!TH k8Dg0CloseFile51Testing软件测试网+t(lR.N|X$B s

g-`'M.m8w D0' Function To Open the HTML file51Testing软件测试网sru D y:k#{d$jF$G
51Testing软件测试网{#N_Tv
Function OpenFile(strFileName)
,QYlN/JM?0StartTime = Timer51Testing软件测试网s:m0cUCm)w-c
stTime = Time51Testing软件测试网4Gc+X)_#p"I
Set fso = CreateObject("Scripting.FileSystemObject")
e6fW F4K0Set ts = fso.OpenTextFile(strFileName, ForWriting, True)
*A:DK-x Nq8o0strFileURL = strFileName
?&NzR$\`$Mm0CreateHeader51Testing软件测试网3W.Pk,q~a
End Function51Testing软件测试网4`E(R1d~ u
51Testing软件测试网6F,`E&wxZDn O }
' Function To Create Header51Testing软件测试网*C3Xj'Y"Tq
51Testing软件测试网Eq,V-E|$w!G.mk
Function CreateHeader()51Testing软件测试网 y}%h A6i5a,o;ve mF1P
ts.writeline("<html>")51Testing软件测试网D0C0L5^9x:Se{;`z
ts.writeline("<title>Test Results</title>")51Testing软件测试网2Q] M N{4` D8Z
ts.WriteLine("<head></head>")
G+q2M'R{] i0ts.WriteLine("<body>")51Testing软件测试网3Q5lN-C+TVm
ts.WriteLine("<font face='Tahoma'size='2'>")
UT(YGV}S0ts.WriteLine("<h1>Test Results</h1>")51Testing软件测试网 {.\7vaJ5g~v
ts.writeline("<table border='0' width='100%' height='47'>")51Testing软件测试网'D9E*[b.v;]
ts.writeline("<tr>")51Testing软件测试网}p$l RQ
ts.writeline("<td width='13%' bgcolor='#CCCCFF' align='center'><b><font color='#000000' face='Tahoma' size='2'>TestCaseID</font></b></td>")
+L [+xY`!` ]0ts.writeline("<td width='24%' bgcolor='#CCCCFF'><b><font color='#000000' face='Tahoma' size='2'>Objective</font></b></td>")51Testing软件测试网VNi W%K(]#CZ8{"C
ts.writeline("<td width='23%' bgcolor='#CCCCFF'><b><font color='#000000' face='Tahoma' size='2'>Expected Result</font></b></td>")
f5iROu0ts.writeline("<td width='22%' bgcolor='#CCCCFF'><b><font color='#000000' face='Tahoma' size='2'>Actual Result</font></b></td>")51Testing软件测试网!^nv+\u
ts.writeline("<td width='18%' bgcolor='#CCCCFF' align='center'><b><font color='#000000' face='Tahoma' size='2'>Pass/Fail</font></b></td>")
9ni:o N$`-AZ nGG9m4[0ts.writeline("</tr>")51Testing软件测试网W4Dz pU7G4Bh$Q*H
End Function51Testing软件测试网#Id(gg:Bd Vs#e Z+k
51Testing软件测试网+h"?#V+?/C(FxLY
' Function To Add New Case51Testing软件测试网Yb5n2A$d
51Testing软件测试网Z$H/V(~(xQ.lV
Function AddNewCase(strTCID,strObjective,strExpectedResult,strActualResult,strPassFail)
.ln{0B1a ~4bV"wJ0ts.writeline("<tr>")
9l!} `Il_0ts.writeline("<td width='13%' bgcolor='#FFFFDC' valign='middle' align='center'>" & strTCID & "</td>")
Yj1K6ywf,Au{0ts.writeline("<td width='24%' bgcolor='#FFFFDC' valign='top' align='justify'>" & strObjective & "</td>")
V'P6C+}dF0ts.writeline("<td width='23%' bgcolor='#FFFFDC' valign='top' align='justify'>" & strExpectedResult & "</td>")51Testing软件测试网2Naq~0j&T.w
ts.writeline("<td width='22%' bgcolor='#FFFFDC' valign='top' align='justify'>" & strActualResult & "</td>")51Testing软件测试网7rrw"p5C6n#Xo2R {"Y
if strPassFail = "Pass" then
:z2A;~n-z0ts.writeline("<td width='18%' bgcolor='#FFFFDC' valign='middle' align='center'><b><font color='Green' face='Tahoma' size='2'>" & strPassFail & "</font></b></td>")
@5mXT1bph0intPass = intPass + 1
f_;a/v[`L0else
7Fs!v+Hej x |0ts.writeline("<td width='18%' bgcolor='#FFFFDC' valign='middle' align='center'><b><font color='Red'
l@vPce:Z#]*~:o0face='Tahoma' size='2'>" & strPassFail & "</font></b></td>")51Testing软件测试网S%sD)LNvm~(uT
intFail = intFail + 1
C*Z1B$\ hh d$wc0end if51Testing软件测试网%ujLM.X$grS/Y
ts.writeline("</tr>")
;{Lx { v0End Function
8D&Z;jX l0
E/q+v*G+ou(k6HA0' Function To Footer Info
M+xnoE{b"x0
!x \7F1F"c0Function Footer()
rfG8m.AK"@}#M0Dim EndTime51Testing软件测试网9|@`v.B
EndTime = Timer51Testing软件测试网 t$f1^_2@T
enTime = Time
~ |5GCv G5YP9t!d0ts.writeline("</table>")51Testing软件测试网 b^G X KD iT/f D V
ts.writeline("<hr>")51Testing软件测试网su{#f fzc9J
ts.writeline("<table border='0' width='50%'>")
,S(P*e-| An0ts.writeline("<tr><td width='100%' colspan='2' bgcolor='#000000'><b><font face='Tahoma' size='2' color='#FFFFFF'>Summary</font></b></td></tr>")51Testing软件测试网3Q}-Eh@F0G/l L
ts.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>")51Testing软件测试网*v N*u+~{ Gu(?
ts.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>")51Testing软件测试网 R6TC$BX4f*C7i9TB
ts.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软件测试网J,X-]Z Ds6o QM;x
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>")51Testing软件测试网(t5f"KH)\(LV-f}5V
ts.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>")51Testing软件测试网*H6iDe6vc3M
ts.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>")
W:eeV#sBG'[Fc0ts.writeline("</table>")
0t L gB,}bhh0ts.writeline("</font>")
.H5z2HO8o*N!Tb/Jb ?0ts.WriteLine("</body>")51Testing软件测试网:T,_3D5L7T m qx
ts.WriteLine("</html>")
H;UQ {~l5j0End Function
XP"}"i&w4d6S"l051Testing软件测试网&ir Kj\4G3jE
' Function To Close File51Testing软件测试网2l:b L0q~_Q G!_
51Testing软件测试网9v7_%p g{S3rnE(os
Function CloseFile()51Testing软件测试网;Gg+p#c s~-s
Footer
9}d ]8ZYr*j S0ts.close()
wUD(q0B0Set bjIE = CreateObject("InternetExplorer.Application")51Testing软件测试网 K+@ T$@1S"T(j.?%z
objIE.visible = True51Testing软件测试网.ZQr#wqY
objIE.Navigate strFileURL
8N K%HCL0End Function

TAG: HTML QTP Report Functions

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

评分:0

我来说两句

Open Toolbar