📅  最后修改于: 2020-12-06 10:46:01             🧑  作者: Mango
可以使用HP-QTP提供的COM接口使QTP本身自动化。自动化对象模型是一组对象,方法和属性,可帮助测试人员使用QTP接口控制配置设置和执行脚本。下面列出了可以控制(但不限于)的关键配置/动作-
QTP 11.5x提供了有关自动化对象模型的专有文档,可以通过导航到“开始” >>“所有程序” >>“ HP软件” >>“ HP统一功能测试” >>“文档” >>“统一”来引用功能测试自动化参考”。
测试人员可以使用“生成脚本”选项从QTP本身生成AOM脚本。导航到“运行” >>“设置” >>“属性”选项卡>>“生成脚本”,如下所示-
' A Sample Script to Demostrate AOM
Dim App 'As Application
Set App = CreateObject("QuickTest.Application")
App.Launch
App.Visible = True
App.Test.Settings.Launchers("Web").Active = False
App.Test.Settings.Launchers("Web").Browser = "IE"
App.Test.Settings.Launchers("Web").Address = "http://easycalculation.com/"
App.Test.Settings.Launchers("Web").CloseOnExit = True
App.Test.Settings.Launchers("Windows Applications").Active = False
App.Test.Settings.Launchers("Windows Applications").Applications.RemoveAll
App.Test.Settings.Launchers("Windows Applications").RecordOnQTDescendants = True
App.Test.Settings.Launchers("Windows Applications").RecordOnExplorerDescendants = False
App.Test.Settings.Launchers("Windows Applications").RecordOnSpecifiedApplications = True
App.Test.Settings.Run.IterationMode = "rngAll"
App.Test.Settings.Run.StartIteration = 1
App.Test.Settings.Run.EndIteration = 1
App.Test.Settings.Run.ObjectSyncTimeOut = 20000
App.Test.Settings.Run.DisableSmartIdentification = False
App.Test.Settings.Run.OnError = "Dialog"
App.Test.Settings.Resources.DataTablePath = ""
App.Test.Settings.Resources.Libraries.RemoveAll
App.Test.Settings.Web.BrowserNavigationTimeout = 60000
App.Test.Settings.Web.ActiveScreenAccess.UserName = ""
App.Test.Settings.Web.ActiveScreenAccess.Password = ""
App.Test.Settings.Recovery.Enabled = True
App.Test.Settings.Recovery.SetActivationMode "OnError"
App.Test.Settings.Recovery.Add "D:\GUITest2\recover_app_crash.qrs",
"Recover_Application_Crash", 1
App.Test.Settings.Recovery.Item(1).Enabled = True
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' System Local Monitoring settings
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
App.Test.Settings.LocalSystemMonitor.Enable = false
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Log Tracking settings
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
With App.Test.Settings.LogTracking
.IncludeInResults = False
.Port = 18081
.IP = "127.0.0.1"
.MinTriggerLevel = "ERROR"
.EnableAutoConfig = False
.RecoverConfigAfterRun = False
.ConfigFile = ""
.MinConfigLevel = "WARN"
End With