1
votes

I am running an automated test script using UFT 12.52. I am wondering if there is a way to export results from within a function in the UFT Script. The idea is to call the function and export the run results.

I can do it externally by creating a .vbs file which launches the script in uft and runs and exports the result, but i cannot figure out how to do it from within a UFT Script as function.

Below is my code for exporting results externally.

Thanks

Dim qtApp 
Dim qtTest 
Dim qtResultsOpt 
Dim qtAutoExportResultsOpts 

Set qtApp = CreateObject("QuickTest.Application") 
qtApp.Launch 
qtApp.Visible = True 


qtApp.Options.Run.ImageCaptureForTestResults = "OnError"

qtApp.Options.Run.RunMode = "Fast"
qtApp.Options.Run.ViewResults = False

qtApp.Open "Z:\D:\paperlessEnhancements\", True 


Set qtTest = qtApp.Test
qtTest.Settings.Run.IterationMode = "rngIterations" 
qtTest.Settings.Run.StartIteration = 1
qtTest.Settings.Run.EndIteration = 1
qtTest.Settings.Run.OnError = "NextStep" 

Set qtResultsOpt = CreateObject("QuickTest.RunResultsOptions") 
qtResultsOpt.ResultsLocation = "C:\Tests\Test1\Res1" n

Set qtAutoExportResultsOpts = qtApp.Options.Run.AutoExportReportConfig
qtAutoExportResultsOpts.AutoExportResults = True 
qtAutoExportResultsOpts.StepDetailsReport = True 
qtAutoExportResultsOpts.DataTableReport = True 
qtAutoExportResultsOpts.LogTrackingReport = True
qtAutoExportResultsOpts.ScreenRecorderReport = True
qtAutoExportResultsOpts.SystemMonitorReport = False 
qtAutoExportResultsOpts.ExportLocation =
"C:\Documents and Settings\All  Users\Desktop" 
qtAutoExportResultsOpts.UserDefinedXSL = "C:\Documents and Settings\All 
Users\Desktop\MyCustXSL.xsl" 
qtAutoExportResultsOpts.StepDetailsReportFormat = "UserDefined" 
qtAutoExportResultsOpts.ExportForFailedRunsOnly = True 

qtTest.Run qtResultsOpt 

MsgBox qtTest.LastRunResults.Status 
qtTest.Close 
Set qtResultsOpt = Nothing
Set qtTest = Nothing 
Set qtApp = Nothing
Set qtAutoExportSettings = Nothing 

I also tried this :

Dim qtResultsOpt 
Dim qtAutoExportResultsOpts 


Set qtResultsOpt = CreateObject("QuickTest.RunResultsOptions") 
qtResultsOpt.ResultsLocation = "C:\Temp\Notepad1" 
Set qtResultsOpt = Nothing
1
Checkout this link.ManishChristian
@ManishChristian Looks like they want to do this on code, not with UFT options (there is a PS in the question from the link)Victor Moraes
thanks for the responses. I checked out the link and am aware of the way to set it to export using gui. Ideally, I would like to call a function in the UFT script that will export the result to a shared folder. The above code will do this, but it is a solution that will be called outside the script. I am trying to figure out how to export the results as the script is running and at the end of the script. Thanks.Lukeriggz
@VictorMoraes, that PS was added after I answered the question.ManishChristian
@Lukeriggz, UFT will generate the run result once the script is executed, I don't think you can export the result before that. If you'll set that option to export the result automatically, ultimately you'll fulfill the same purpose. What will you achieve by exporting result through script? I am trying to understand here.ManishChristian

1 Answers

0
votes

@Lukeriggz :Attach a function library to all your script and the function library should be called in first place in your script(Either you can call the lines in your current library function itself. But the significance is to set the attribute at the first place and start with the execution). The content of the library should be the one which you have shown the code except the Open,run statement and releasing the objects(Primarily the configuration statements should be there). This will make your result location always pointed to your desired path and you can view the results. While configuration of the script have the script name in a variable to create the result file name to act is as dynamic

Another Implementation We can easily identify where the results are getting saved Using the inbuilt environment variable. So programmatically we can copy the folder using file system objects

enter code here

executionpath=Environment.Value("ResultDir")
path_to_save_the_results= "Type your path where the results should be saved" 
fso.CopyFolder executionpath, path_to_save_the_results