用于在脚本失败时启用图像捕获的QTP AOM代码无效

时间:2016-01-22 10:21:37

标签: hp-uft

在脚本失败时启用图像捕获的QTP AOM代码无法正常工作

我使用以下代码启用QTP屏幕捕获选项,但它没有存储任何屏幕截图:

代码:

Dim App
Dim qtTest

'Create the QTP Application object
Set App = CreateObject("QuickTest.Application")

'If QTP is notopen then open it
If  App.launched <> True then

App.Launch

End If

'Make the QuickTest application visible
App.Visible = True

'Set QuickTest run options
'Instruct QuickTest to perform next step when error occurs

App.Options.Run.ImageCaptureForTestResults = "OnError"
App.Options.Run.RunMode = "Fast"
App.Options.Run.ViewResults = True

'Open the test in read-only mode
App.Open "D:\GUITest4", True

'set run settings for the test
Set qtTest = App.Test

'Instruct QuickTest to perform next step when error occurs
qtTest.Settings.Run.OnError = "NextStep"

'Run the test
qtTest.Run


'Check the results of the test run
MsgBox qtTest.LastRunResults.Status

' Close the test
qtTest.Close

'Close QTP
'App.quit

'Release Object
Set qtTest = Nothing
Set App = Nothing

有人可以帮忙吗?

2 个答案:

答案 0 :(得分:0)

尝试此操作以捕获屏幕截图:

设置obj =桌面
 obj.capturebitmap strFileName&amp; &#34; png格式&#34;

要将屏幕截图嵌入结果本身,请在strFileName参数中提供结果路径: strFileName = Environment.Value(&#34; ResultDir&#34;)&amp; &#34; \&#34; &安培; Mid(Environment.Value(&#34; ActionName&#34;),1,15)&amp; filename.png

答案 1 :(得分:0)

使用 QTP AOM ,我们可以捕获将存储在结果文件夹中的屏幕截图,可以通过以下代码进行控制。

Set qtApp = CreateObject("QuickTest.Application")
qtApp.Options.Run.ImageCaptureForTestResults = "OnError"
qtApp.Open "C:\Tests\Test1", True

Set qtTest = qtApp.Test

Set qtResultsOpt = CreateObject("QuickTest.RunResultsOptions") 

创建“运行结果选项”对象

qtResultsOpt.ResultsLocation = "C:\Tests\Test1\Res1" 

设置结果位置

 qtTest.Run qtResultsOpt 

运行测试

qtTest.Close

希望它有所帮助,让我知道结果