不要追求绝对的公平,红尘之中没有公平而言,人活一世,难得糊涂。
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软件测试网w`x[%b*a5EnP
%?+r2Z8n+w$P"|!f0Dim fso, ts51Testing软件测试网8f
a
fAbT1Yr
dim intCnt51Testing软件测试网5m6F(o+A2z5\'`Va
Const ForWriting = 2
t;bj6b,y,@ V0dim intPass,intFail51Testing软件测试网%t Mi1tI+_y!}
dim StartTime
$d0W6T\Rx i0dim stTime51Testing软件测试网6oU*On'N(n-@
dim enTime
r~T\R
{\:@$F0dim objIE51Testing软件测试网hNa?w2m
dim strFileURL
|g#e`A0
!FU'^^5No,pbMGR0'Implementation
U3M{
c[&_9U0OpenFile "C:\Test.html"
6d]v2rP5V0AddNewCase 1,"X","X","X","Pass"51Testing软件测试网a
az8T4S[0vhdw]
AddNewCase 2,"X","X","X","Fail"51Testing软件测试网;I{'_npM*q4e
AddNewCase 3,"X","X","X","Pass"
:t3d
l|8C+x7I P0CloseFile
5F`DC
P#U0
~g*h,t6^"x`0' Function To Open the HTML file51Testing软件测试网rC8h D-emD?1T-b2O&P
*BF3?@ b@ ?0Function OpenFile(strFileName)
9nQyAInD0StartTime = Timer
5|2V7k7Ic"F0stTime = Time51Testing软件测试网Q0Im#pL
Set fso = CreateObject("Scripting.FileSystemObject")51Testing软件测试网1y,^l)Q2^:e0Sx
Set ts = fso.OpenTextFile(strFileName, ForWriting, True)
1\)OG2_GrLI6Y0strFileURL = strFileName
[ C/LV6F*\#B0CreateHeader
Fpp@1BF2Y0End Function
e.xI8k/RQpU
T051Testing软件测试网,~HqzE]M-a
' Function To Create Header51Testing软件测试网0hPC%Ng
51Testing软件测试网&YW,CK
?1V ?
Function CreateHeader()
n?J{Du#Z*N0ts.writeline("<html>")
%Cx4N^&J,t1_;|$Q0ts.writeline("<title>Test Results</title>")
8]*Us.`4sH`0ts.WriteLine("<head></head>")
[Z"IL!c nAT[ B0ts.WriteLine("<body>")
]"Y0p$WDTC,i)x0ts.WriteLine("<font face='Tahoma'size='2'>")51Testing软件测试网`E Js&\
ts.WriteLine("<h1>Test Results</h1>")
+i5Sc[s~&[0ts.writeline("<table border='0' width='100%' height='47'>")
zR6lfa$?s w0ts.writeline("<tr>")
Iu9T5m8_m0ts.writeline("<td width='13%' bgcolor='#CCCCFF'
align='center'><b><font color='#000000' face='Tahoma'
size='2'>TestCaseID</font></b></td>")51Testing软件测试网v@#O{I;o
ts.writeline("<td width='24%' bgcolor='#CCCCFF'><b><font
color='#000000' face='Tahoma'
size='2'>Objective</font></b></td>")
*l Z7] O
~Ts)@0ts.writeline("<td width='23%' bgcolor='#CCCCFF'><b><font
color='#000000' face='Tahoma' size='2'>Expected
Result</font></b></td>")
,G;\ C3c1t0ts.writeline("<td width='22%' bgcolor='#CCCCFF'><b><font
color='#000000' face='Tahoma' size='2'>Actual
Result</font></b></td>")51Testing软件测试网6e R_'RF}Q
[
ts.writeline("<td width='18%' bgcolor='#CCCCFF'
align='center'><b><font color='#000000' face='Tahoma'
size='2'>Pass/Fail</font></b></td>")
Wk ?7j ^Zb0ts.writeline("</tr>")51Testing软件测试网l@ u7WeP
End Function
!rlUn3a)jR#E0
;wq.HQ$gT,X0' Function To Add New Case51Testing软件测试网3L"|#c8u|k+s
xR}a2V ne1`0Function AddNewCase(strTCID,strObjective,strExpectedResult,strActualResult,strPassFail)
h^9Hzi%E0ts.writeline("<tr>")51Testing软件测试网?Ni\d
o0`~
ts.writeline("<td width='13%' bgcolor='#FFFFDC' valign='middle' align='center'>" & strTCID & "</td>")51Testing软件测试网obzlD.A
ts.writeline("<td width='24%' bgcolor='#FFFFDC' valign='top' align='justify'>" & strObjective & "</td>")
Al_A rf;ik0ts.writeline("<td width='23%' bgcolor='#FFFFDC' valign='top'
align='justify'>" & strExpectedResult & "</td>")
%QU2Yrg5?8^uW
w0ts.writeline("<td width='22%' bgcolor='#FFFFDC' valign='top' align='justify'>" & strActualResult & "</td>")51Testing软件测试网E NE8kN{!u H6x
if strPassFail = "Pass" then
2yq7Sw,n'uRD0ts.writeline("<td width='18%' bgcolor='#FFFFDC' valign='middle'
align='center'><b><font color='Green' face='Tahoma'
size='2'>" & strPassFail &
"</font></b></td>")51Testing软件测试网3c!@_C
z&v
intPass = intPass + 1
jEn?;JjZ0else51Testing软件测试网P)](]7U#hy`;w
ts.writeline("<td width='18%' bgcolor='#FFFFDC' valign='middle' align='center'><b><font color='Red'51Testing软件测试网$v!JuH@5HV%y2j
face='Tahoma' size='2'>" & strPassFail & "</font></b></td>")51Testing软件测试网r#f(Q~*BS
intFail = intFail + 151Testing软件测试网)tLdF;@0B9A#~h
end if
!t9Xl$uE}8y0ts.writeline("</tr>")
7i9dS4Q2RRz&R7lh8m0End Function
3Q2rk1G4H4_.|+e0
)k$GqLnql U0i0' Function To Footer Info
"T({BA_3s"n0
JJ:`G%G2|cG~j0Function Footer()
]8E;\;?#K/AGH0Dim EndTime51Testing软件测试网Bm4a+Oa
EndTime = Timer51Testing软件测试网UY_C
J9U.|
enTime = Time
Y5z^ AF0ts.writeline("</table>")51Testing软件测试网UK.[Hb.[/ZMA
ts.writeline("<hr>")
xJ;`pe0ts.writeline("<table border='0' width='50%'>")
CsHZv `9}ol~0ts.writeline("<tr><td width='100%' colspan='2'
bgcolor='#000000'><b><font face='Tahoma' size='2'
color='#FFFFFF'>Summary</font></b></td></tr>")
+A$qx(P
n.^w0ts.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软件测试网5`I5R(@6QGRc
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>")
m o5N%TE5RU ~"D$b*Kg0ts.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软件测试网:dl9P!O2q Qt1nbT
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软件测试网'P;U? \5?0oc!j1DJe
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>")
O$z!CH:u w-x0ts.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>")51Testing软件测试网7LE)]TXS8Xx
ts.writeline("</table>")
5x)Zq.I;@{0ts.writeline("</font>")51Testing软件测试网)?qmQPXLf%`5z
ts.WriteLine("</body>")51Testing软件测试网LIjLF$o%F
ts.WriteLine("</html>")51Testing软件测试网fhli.[5Vn5Q0f W
End Function51Testing软件测试网!LEO hl
B'R:Ip:Fs_6p0' Function To Close File
C(hA%c1P$|4E7d051Testing软件测试网Q%ql@.d#~q3V
Function CloseFile()51Testing软件测试网
]&An
B-jok
Footer51Testing软件测试网M\myI Q'DO
ts.close()51Testing软件测试网H#j a)NI9{
Set bjIE = CreateObject("InternetExplorer.Application")51Testing软件测试网1D3m7x;df_b+aj3@v
objIE.visible = True
x*}?po%G(LFC_0objIE.Navigate strFileURL
0l.r*w2hng~%A0End Function
相关阅读:
- 我的QTP实习总结 (51testing, 2009-5-31)
- QTP:搜索功能测试 (aslandhu, 2009-5-31)
- QTP实例:搜索功能测试 (fishy, 2009-6-02)
- QTP实例:使用JS操作ActiveX控件 (fishy, 2009-6-03)
- QTP启动应用程序分析 (51testing, 2009-6-04)
- 对QTP自动化测试框架的一点认识 (fishy, 2009-6-05)
- 浅谈QTP描述性编程(含实例) (fishy, 2009-6-08)
- QTP日期控件识别与参数化 (fishy, 2009-6-09)
- QTP的几种同步等待方法 (fishy, 2009-6-10)
- QTP10.0带来的些许变化 (fishy, 2009-6-10)
收藏
举报
TAG:
HTML
QTP
Report
Functions