如何把信息写到TestResults中
在使用QTP时,我想要把执行输出结果写入到TestResults中,不知道怎么写那你想要怎么写啊
这是report的样式 你可以看看 Private Function CreateResultFile(FilePath)''' <value type="Excel.Worksheet"/>
Dim objSheet
'Disable alerts
oEngine.DisplayAlerts = False
'Add a workbook to the Excel App
oEngine.Workbooks.Add
'Get the object of the first sheet in the workbook
Set objSheet = oEngine.Sheets.Item(1)
oEngine.Sheets.Item(1).Select
With objSheet
'Rename the first sheet to "Test_Summery"
.Name = "Test_Summary"
'Set the Heading
.Range("B1").Value = "Test Results"
.Range("B1:C1").Merge
'Set color and Fonts for the Header
.Range("B1:C1").Interior.ColorIndex = 53
.Range("B1:C1").Font.ColorIndex = 19
.Range("B1:C1").Font.Bold = True
'Set the Date and time of Execution
.Range("B3").Value = "Test Date: "
.Range("B4").Value = "Test Start Time: "
.Range("B5").Value = "Test End Time: "
.Range("B6").Value = "Test Duration: "
.Range("C3").Value = Date
.Range("C4").Value = Time
.Range("C5").Value = Time
.Range("C6").Value = "=R[-1]C-R[-2]C"
.Range("C6").NumberFormat = ":mm:ss;@"
'Set the Borders for the Date & Time Cells
.Range("B3:C8").Borders(1).LineStyle = 1
.Range("B3:C8").Borders(2).LineStyle = 1
.Range("B3:C8").Borders(3).LineStyle = 1
.Range("B3:C8").Borders(4).LineStyle = 1
'Format the Date and Time Cells
.Range("B3:C8").Interior.ColorIndex = 40
.Range("B3:C8").Font.ColorIndex = 12
.Range("B3:A8").Font.Bold = True
'Track the Row Count and insrtuct the viewer not to disturb this
.Range("C7").AddComment
.Range("C7").Comment.Visible = False
.Range("C7").Comment.Text "This is a very Important field for the script." & vbCrLf & "Please Do not Edit or Delete."
.Range("C7").Value = "0"
.Range("B7").Value = "No Of Testcases:"
'Track the Testcase Count Count and insrtuct the viewer not to disturb this
.Range("C8").AddComment
.Range("C8").Comment.Visible = False
.Range("C8").Comment.Text "This is a very Important field for the script." & vbCrLf & "Please Do not Edit or Delete."
.Range("C8").Value = "0"
.Range("B8").Value = "Total No Of Test Steps:"
.Range("B10").Value = "TestCase Name"
.Range("C10").Value = "Status"
.Range("D10").Value = "No Of Steps"
.Range("E10").Value = "*Click the TestCase Name to see detail result."
'Format the Heading for the Result Summery
.Range("B10:D10").Interior.ColorIndex = 53
.Range("B10:D10").Font.ColorIndex = 19
.Range("B10:D10").Font.Bold = True
'Set the Borders for the Result Summery
.Range("B10:D10").Borders(1).LineStyle = 1
.Range("B10:D10").Borders(2).LineStyle = 1
.Range("B10:D10").Borders(3).LineStyle = 1
.Range("B10:D10").Borders(4).LineStyle = 1
'Set Column width
.Columns("B:D").Select
.Columns("B:D").Autofit
.Range("B11").Select
End With
'Freez pane
oEngine.ActiveWindow.FreezePanes = True
'Get the object of the first sheet in the workbook
Set objSheet = oEngine.Sheets.Item(2)
oEngine.Sheets.Item(1).Select
With objSheet
'Rename the first sheet to "Test_Result"
.Name = "Test_Result"
'Set the Column widths
.Columns("A:A").ColumnWidth = 30
.Columns("B:B").ColumnWidth = 8
.Columns("C:D").ColumnWidth = 35
.Columns("E:E").ColumnWidth = 35
.Columns("A:E").HorizontalAlignment = -4131
.Columns("A:E").WrapText = True
'Set the Heading for the Result Columns
.Range("A1").Value = "STEP NAME"
.Range("B1").Value = "STATUS"
.Range("C1").Value = "EXPECTED RESULT"
.Range("D1").Value = "ACTUAL RESULT"
.Range("E1").Value = "ERROR MESSAGE"
'Format the Heading for the Result Columns
.Range("A1:E1").Interior.ColorIndex = 53
.Range("A1:E1").Font.ColorIndex = 19
.Range("A1:E1").Font.Bold = True
'Set the Borders for the Result Header
.Range("A1:E1").Borders(1).LineStyle = 1
.Range("A1:E1").Borders(2).LineStyle = 1
.Range("A1:E1").Borders(3).LineStyle = 1
.Range("A1:E1").Borders(4).LineStyle = 1
' .Range("A2").Select
End With
'Freez pane
oEngine.ActiveWindow.FreezePanes = True
'Save the Workbook at the specified Path with the Specified Name
oEngine.ActiveWorkbook.saveas FilePath
'Relese the Object
Set objSheet = Nothing
End Function
[ 本帖最后由 Spark.lee 于 2009-6-25 14:26 编辑 ]
回复 2# 的帖子
我想楼主想知道的是写入内容到执行后的报告中吧.不是写到excel中吧.
如果是要写入执行报告中,你用reporter
这样:
reporter.ReportEvent micPass,"写入报告的标题","写入报告的内容"
你可以去查这个事件的详细描述.以便更灵活运用他 我使用Report Object写入的,感谢大家的回帖!:) 2楼列出的reporter引擎,我做了一些优化,改变了页面的风格,增加了续写功能和分类统计功能.效果如附件. 这年头啥都要钱啊,连改写别人的也要收费,人家原创 的都不要钱.
页:
[1]