Web测试

写HTML日志

上一篇 / 下一篇  2013-07-25 22:37:45 / 个人分类:测试总结

Const Forreading=1,ForWriting=2,ForAppending=8

'''创建html日志头部
Function CreateHtmlLog()
    Dim fso,htmlLog
    Set fso=CreateObject("scripting.FileSystemObject")
    Set htmlLog=fso.OpenTextFile("D:\test.txt",ForAppending)  '文件地址可参数化
    htmlLog.WriteLine("<html>")
    htmlLog.WriteLine("<head>")
    htmlLog.WriteLine("<title>")
    htmlLog.WriteLine("TestReport")
    htmlLog.WriteLine("</title>")
    htmlLog.WriteLine("</head>")
    htmlLog.WriteLine("<body>")
    htmlLog.WriteLine("<table>")
    htmlLog.WriteLine("<tr>")
    htmlLog.WriteLine("<td colspan='6' bgcolor='#CCCCCC' height='40'  width='20%' align='center'><b>测试报告</b></td>")
    htmlLog.WriteLine("</tr>")
    htmlLog.WriteLine("<tr>")
    htmlLog.WriteLine("<td bgcolor='#CCCCCC' height='40'  width='20%' align='center'><b>TestCaseName</b></td>")
    htmlLog.WriteLine("<td bgcolor='#CCCCCC' height='40'  width='20%' align='center'><b>TestCaseID</b></td>")
    htmlLog.WriteLine("<td bgcolor='#CCCCCC' height='40'  width='10%' align='center'><b>TestResult</b></td>")
    htmllog.WriteLine("<td bgcolor='#CCCCCC' height='40'  width='10%' align='center'><b>TestTime</b></td>")
    htmlLog.WriteLine("<td bgcolor='#CCCCCC' height='40'  width='20%' align='center'><b>ActualValue</b></td>")
    htmlLog.WriteLine("<td bgcolor='#CCCCCC' height='40'  width='20%' align='center'><b>ExceptValue</b></td>")
    htmlLog.WriteLine("</tr>")
    Set htmlLog=Nothing
    Set fso=Nothing
EndFunction

'''写html日志
Function WriteHtmlLog(TestCaseName,TestCaseID,TestResult,TestResult,TestResult,ExceptValue)
    Dim fso,htmlLog
    Set fso=CreateObject("scripting.FileSystemObject")
    Set htmlLog=fso.OpenTextFile("D:\test.txt",ForAppending) '文件地址可参数化
    htmlLog.WriteLine("<tr>")
    htmlLog.WriteLine("<td bgcolor='#CCCCCC' height='40'  width='20%' align='center'><b>"&TestCaseName&"</b></td>")
    htmlLog.WriteLine("<td bgcolor='#CCCCCC' height='40'  width='20%' align='center'><b>"&TestCaseID&"</b></td>")
    '如果测试结果为PASS,则用绿色字体,如果测试结果为Fail,则用红色字体
    If TestResult="PASS"Then
        htmlLog.WriteLine("<td bgcolor='#CCCCCC' height='40'  width='10%' align='center'><font color="Green"><b>"&TestResult&"</b></font></td>")
    Else
        htmlLog.WriteLine("<td bgcolor='#CCCCCC' height='40'  width='10%' align='center'><font color="red"><b>"&TestResult&"</b></font></td>")
    EndIf
    htmllog.WriteLine("<td bgcolor='#CCCCCC' height='40'  width='10%' align='center'><b>"&TestTime&"</b></td>")
    htmlLog.WriteLine("<td bgcolor='#CCCCCC' height='40'  width='20%' align='center'><b>"&ActualValue&"</b></td>")
    htmlLog.WriteLine("<td bgcolor='#CCCCCC' height='40'  width='20%' align='center'><b>"&ExceptValue&"</b></td>")
    htmlLog.WriteLine("</tr>")
    htmlLog.WriteLine("</table>")
    htmlLog.WriteLine("</body>")
    htmlLog.WriteLine("</html>")
    Set htmlLog=Nothing
    Set fso=Nothing
EndFunction

TAG:

 

评分:0

我来说两句

jing17

jing17

有梦想 有激情 ~@! 放飞无限青春 像鹰一样翱翔 ~#@

日历

« 2024-03-23  
     12
3456789
10111213141516
17181920212223
24252627282930
31      

数据统计

  • 访问量: 14968
  • 日志数: 19
  • 建立时间: 2012-05-19
  • 更新时间: 2013-08-18

RSS订阅

Open Toolbar