问题
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?
Here is the code:
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
What this code does: it creates Word document, but doesn't store run results.
P.S. I want to store run-results using driver script, not "options" in UFT
回答1:
UFT provides options to export run result in three different formats.
HTML
PDF
DOC
All you have to do is:
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
Now every time you'll execute the script, UFT will store the run result for you on specified location.
Note:
You won't be able export Data, Screen Recorder and Log Tracking
information.
来源:https://stackoverflow.com/questions/33663495/how-to-store-run-results-from-qtp-to-word-file