QTP - 自动化对象模型
QTP 本身可以使用 HP-QTP 提供的 COM 接口实现自动化。自动化对象模型是一组对象、方法和属性,可帮助测试人员控制配置设置并使用 QTP 接口执行脚本。可以控制的关键配置/操作(但不限于)列于下方 −
- 加载测试所需的所有插件
- 执行时使 QTP 可见
- 使用指定位置打开测试
- 关联函数库
- 指定通用对象同步超时
- 开始和结束迭代
- 启用/禁用智能识别
- 错误设置
- 数据表路径
- 恢复场景设置
- 日志跟踪设置
QTP 11.5x 提供了有关自动化对象模型的独家文档,可通过导航至"开始">> "所有程序">> 来参考。 "HP 软件" >> "HP Unified Functional Testing" >> "文档" >> "Unified Functional Testing Automation Reference"。
生成 AOM 脚本
测试人员可以使用"生成脚本"选项从 QTP 本身生成 AOM 脚本。导航到"运行" >> "设置" >> "属性"选项卡 >> "生成脚本",如下所示 −
示例
' 演示 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 = "<Default>" 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 ecover_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