不要追求绝对的公平,红尘之中没有公平而言,人活一世,难得糊涂。                                           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 / 个人分类:自动化测试

每日随笔
  • 每日随笔:
' Variables51Testing软件测试网l0y'g!}g(i g
51Testing软件测试网gUZ&~:~#Xo$M'm%?
Dim fso, ts51Testing软件测试网o0o`"NJ
dim intCnt51Testing软件测试网.B Ub^]HmR
Const ForWriting = 251Testing软件测试网f%gHDn*b s
dim intPass,intFail
g&SxU%z0dim StartTime
4a"U,^5B/aPh8~0dim stTime
b `.v*f6n/vybw0dim enTime
_3H^&wd9p0dim objIE51Testing软件测试网/kb/D!G x(F
dim strFileURL
O#g,FCesting软件测试网knK bg$Mqt&F#E
'Implementation51Testing软件测试网?O9]6Ds0G8Jz9r
OpenFile "C:\Test.html"
2q]M:q} ?0AddNewCase 1,"X","X","X","Pass"
,P5w!y;x9X%m3x;y0AddNewCase 2,"X","X","X","Fail"51Testing软件测试网v%S[:{lAi
AddNewCase 3,"X","X","X","Pass"51Testing软件测试网-`su~)]e4pl
CloseFile51Testing软件测试网GGi_7ny#xj JKr

7\e x rA0' Function To Open the HTML file
r+f | wW0
T?bD)EI2M/? l |$G0Function OpenFile(strFileName)51Testing软件测试网 JEiKrN(L
StartTime = Timer
im kBF0stTime = Time
b'ER K3tQ*~0Set fso = CreateObject("Scripting.FileSystemObject")
5u4`r*f Wg"m o[ gG5?0Set ts = fso.OpenTextFile(strFileName, ForWriting, True)51Testing软件测试网YNC4jE_U;|
strFileURL = strFileName51Testing软件测试网wS7M'x@
CreateHeader51Testing软件测试网l6hlm*Sjv;N{
End Function51Testing软件测试网 yCd6vEn3Fg0\
51Testing软件测试网*s8zD IU,?{kO
' Function To Create Header
5NP$u4E7p*a.k051Testing软件测试网 _jh)|O_5\4Z9u
Function CreateHeader()51Testing软件测试网 \?Oc"KsJRF2k%o
ts.writeline("<html>")
4`8AY*E1^rBq0ts.writeline("<title>Test Results</title>")
\6a w X8V|2b2D0ts.WriteLine("<head></head>")51Testing软件测试网8I$c%l_\#g
ts.WriteLine("<body>")51Testing软件测试网^]-x/J*~A1g ^ P"Y
ts.WriteLine("<font face='Tahoma'size='2'>")51Testing软件测试网Qz(|yj$z
ts.WriteLine("<h1>Test Results</h1>")
Qs\6r8Uq/R+o'tG0ts.writeline("<table border='0' width='100%' height='47'>")51Testing软件测试网 pHze` o3VJ
ts.writeline("<tr>")51Testing软件测试网'VS D7oUh?s1v/my
ts.writeline("<td width='13%' bgcolor='#CCCCFF' align='center'><b><font color='#000000' face='Tahoma' size='2'>TestCaseID</font></b></td>")51Testing软件测试网&l!\Mq*u
ts.writeline("<td width='24%' bgcolor='#CCCCFF'><b><font color='#000000' face='Tahoma' size='2'>Objective</font></b></td>")51Testing软件测试网T w {;i9a!S(Hw |2V
ts.writeline("<td width='23%' bgcolor='#CCCCFF'><b><font color='#000000' face='Tahoma' size='2'>Expected Result</font></b></td>")51Testing软件测试网#du A-e(m)?V
ts.writeline("<td width='22%' bgcolor='#CCCCFF'><b><font color='#000000' face='Tahoma' size='2'>Actual Result</font></b></td>")
p'~yH&Y\P%O0ts.writeline("<td width='18%' bgcolor='#CCCCFF' align='center'><b><font color='#000000' face='Tahoma' size='2'>Pass/Fail</font></b></td>")51Testing软件测试网+v C ue6f8d
ts.writeline("</tr>")51Testing软件测试网,e;K\'uf
End Function
:~g @N-ti|0
:u#oC vY+K'H&g1m0' Function To Add New Case
"~umF^q+w!Q0
3`s1y,g9hq e0Function AddNewCase(strTCID,strObjective,strExpectedResult,strActualResult,strPassFail)51Testing软件测试网 v0uUcpc%E
ts.writeline("<tr>")
`?G.c#t.^j3C,Y.~@H0ts.writeline("<td width='13%' bgcolor='#FFFFDC' valign='middle' align='center'>" & strTCID & "</td>")51Testing软件测试网M2U"s6aC2u8~P
ts.writeline("<td width='24%' bgcolor='#FFFFDC' valign='top' align='justify'>" & strObjective & "</td>")
(nt5[TZ6ct0?4P0ts.writeline("<td width='23%' bgcolor='#FFFFDC' valign='top' align='justify'>" & strExpectedResult & "</td>")51Testing软件测试网2j3R&O*|Jv,O
ts.writeline("<td width='22%' bgcolor='#FFFFDC' valign='top' align='justify'>" & strActualResult & "</td>")
/k;R$X!]L7Af0if strPassFail = "Pass" then51Testing软件测试网4ksw f+X/v5]?0_P@v
ts.writeline("<td width='18%' bgcolor='#FFFFDC' valign='middle' align='center'><b><font color='Green' face='Tahoma' size='2'>" & strPassFail & "</font></b></td>")51Testing软件测试网k1fI/G0t
intPass = intPass + 1
bn!Z!y4}"ov \0else51Testing软件测试网:i%ST/[O0}+cl;x(@
ts.writeline("<td width='18%' bgcolor='#FFFFDC' valign='middle' align='center'><b><font color='Red'51Testing软件测试网,?@'A\.a
face='Tahoma' size='2'>" & strPassFail & "</font></b></td>")
wY"H?.O,Ct.J0intFail = intFail + 151Testing软件测试网!yQQ T5q1P-Y2h
end if51Testing软件测试网7vMo-xsq$~y \8T
ts.writeline("</tr>")
R-NE-sY r\0End Function51Testing软件测试网XQ`)}{"c,R$TB
51Testing软件测试网1}2|'fOy
' Function To Footer Info
:|!PyK9M:{051Testing软件测试网-lKWk U(oyv4DO
Function Footer()51Testing软件测试网*wtM1E{T
Dim EndTime51Testing软件测试网@*Y4W&G7T~V
EndTime = Timer
T)oKh J0T?2i0enTime = Time
/?+n}/GMP2EnG%E^0ts.writeline("</table>")
RHO!f KJ&jl0ts.writeline("<hr>")51Testing软件测试网 z;Vki"C `y
ts.writeline("<table border='0' width='50%'>")
`\*hY:@\0ts.writeline("<tr><td width='100%' colspan='2' bgcolor='#000000'><b><font face='Tahoma' size='2' color='#FFFFFF'>Summary</font></b></td></tr>")51Testing软件测试网Yv] `"RH)[ P{
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软件测试网R7Z.t` _ C(}#TOWI
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软件测试网yeo6ZwawJ
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>")
"}L8a-^"t o*{0ts.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软件测试网1Z+m7aLC
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软件测试网8Sd{%tw+eS
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>")
%MYQ r Zk7gR0ts.writeline("</table>")
[c6w ` dys"P0ts.writeline("</font>")51Testing软件测试网j ^o+XVQ
ts.WriteLine("</body>")
7EgVXU0ts.WriteLine("</html>")51Testing软件测试网+rlw\9@V
End Function51Testing软件测试网x&dd9nq8n6a|

1z*b B%A0`\0' Function To Close File
;| DjF6|{051Testing软件测试网 A KXzD z?q'Q
Function CloseFile()51Testing软件测试网LdI)Ik*wJ-]]
Footer
)f1mm8[ d%W0ts.close()
gqm0xO9Li0Set bjIE = CreateObject("InternetExplorer.Application")51Testing软件测试网$P@ ZV~
objIE.visible = True51Testing软件测试网D'e_Q9i#G(W+oGZ5x
objIE.Navigate strFileURL
I(d-Q[ q(P3S)S5Z0End Function

TAG: HTML QTP Report Functions

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

评分:0

我来说两句

Open Toolbar