AutoExport从UFT函数运行结果

时间:2016-07-14 20:04:02

标签: vbscript qtp hp-uft

我正在使用UFT 12.52运行自动化测试脚本。我想知道是否有办法从UFT脚本中的函数中导出结果。我们的想法是调用函数并导出运行结果。

我可以通过创建一个.vbs文件在外部创建,该文件在uft中启动脚本并运行并导出结果,但我无法弄清楚如何在UFT脚本中执行此操作。

以下是我在外部导出结果的代码。

由于

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 

我也试过这个:

Dim qtResultsOpt 
Dim qtAutoExportResultsOpts 


Set qtResultsOpt = CreateObject("QuickTest.RunResultsOptions") 
qtResultsOpt.ResultsLocation = "C:\Temp\Notepad1" 
Set qtResultsOpt = Nothing

1 个答案:

答案 0 :(得分:0)

@Lukeriggz:将函数库附加到您的所有脚本中,并且应该首先在脚本中调用函数库(您可以在当前库函数本身中调用行。但重要的是将属性设置为第一个地方,从执行开始)。库的内容应该是您显示代码的内容,除了Open,run语句和释放对象(主要是配置语句应该在那里)。这将使您的结果位置始终指向您想要的路径,您可以查看结果。虽然脚本的配置在变量中具有脚本名称以创建要执行的结果文件名称为动态

另一项实施 我们可以轻松识别结果的保存位置使用内置环境变量。因此,我们可以通过编程方式使用文件系统对象复制文件夹

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