如何将QTP的运行结果存储到Word文件? [英] How to store run-results from QTP to word file?
问题描述
在UFT中运行脚本之后,我想将结果存储在与测试名称相同或与测试相关的word文档中,因此我可以轻松地区分哪个结果属于哪个测试.
有人可以帮我吗?
After I run my scripts in UFT, I want to store results in a word document that will have the same name as my tests or be relevant to test, so I can easily differentiate which result belong to which test.
Can anyone help me with that?
这是代码:
Dim oWord
Set oWord = CreateObject("Word.Application")
oWord.Documents.Add
oWord.ActiveDocument.Saveas "C:\Users\Desktop\RunResults\TestForWordDocResults2"
Dim oWordTestPath
oWordTestPath = "C:\Users\Desktop\AutomationScripts\TestForWordDocResults"
' Launch QuickTest
Set qtApp = CreateObject("QuickTest.Application") ' Create the Application object
qtApp.Launch ' Start QuickTest
qtApp.Visible = True ' Make the QuickTest application visible
' Run the Test
qtApp.Open oWordTestPath, False ' Open the test
Set qtResultsOpt = CreateObject("QuickTest.RunResultsOptions") 'Create the Run Results Options object
testResults = "C:\Users\Desktop\RunResults"
' Original location for the test results.
qtResultsOpt.ResultsLocation = testResults ' Specify the location to save the test results.
oWordTestPath.Run qtResultsOpt, True ' Run the test and wait until end of the test run
' Close QuickTest Professional
qtApp.Quit
此代码的作用: 它会创建Word文档,但不存储运行结果.
What this code does: it creates Word document, but doesn't store run results.
P.S.我想使用驱动程序脚本而不是UFT中的选项"来存储运行结果
P.S. I want to store run-results using driver script, not "options" in UFT
推荐答案
UFT提供了以三种不同格式导出运行结果的选项.
UFT provides options to export run result in three different formats.
-
HTML
-
PDF
-
DOC
所有您需要做的是:
转到 Options --> Run Sessions
(在常规"标签中)
选中 Automatically export run results when run session ends
的复选框
点击 Configure
选择 Export Type
作为 Doc
对您要导出的详细信息进行必要的更改
指定 Export Location
如果要在所有情况下都导出结果,请取消选中 Export run results only if run session fails
的框
点击 OK
Go to Options --> Run Sessions
(from General tab)
Check the box for Automatically export run results when run session ends
Click on Configure
Select the Export Type
as Doc
Make necessary changes about the details you want to export
Specify the Export Location
Uncheck the box for Export run results only if run session fails
if you want to export result in all cases
Click OK
现在,每次执行脚本时,UFT都会将运行结果存储在指定位置.
Now every time you'll execute the script, UFT will store the run result for you on specified location.
注意:
您将无法导出 Data, Screen Recorder and Log Tracking
信息.
Note:
You won't be able export Data, Screen Recorder and Log Tracking
information.
这篇关于如何将QTP的运行结果存储到Word文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!