用vbs文件启动QTP并运行脚本
|
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
Dim qtApp'创建QTP实例Set qtApp = CreateObject("QuickTest.Application")'启动QTP实例qtApp.LaunchqtApp.Visible = true'打开相应的QTP脚本(如脚本为保存在D盘的Test1)qtApp.Open "D:\Test1"Set qtTest= qtApp.TestSet objTestRecovery = qtApp.Test.Settings.Recovery'设置QTP存储报告的目录Set qtResultsOpt = CreateObject("QuickTest.RunResultsOptions")'运行QTPqtTest.Run qtResultsOpt'运行完毕,退出脚本qtTest.Close'测试任务结束后,退出QTP实例qtApp.quitSet qtApp = Nothing |
检查页面对象是否可用
用GetTOProperty("disabled")获得对象disabled 的属性值,如果为1,则不可用,为0 则可用
回车键
1.WshShell.SendKeys "{ENTER}"
2.ype micReturn
通过object属性返回运行时UI对象的属性
a=wpfwindow("NuICT").Object.Title
获取对象属性并显示
Set Props=WpfWindow("").WpfObject("").GetToPropertities
PropsCount=Props.Count
For i=0 to Props.Count-1
PropName=Props(i).Name
PropValue=Props(i).Value
Msgbox PropName &"="&PropValue
Next
获取鼠标XY坐标
For i = 1 To 10
Wait 2
Print "1. X=" & ctlr.MousePosition.X & "; Y=" & ctlr.MousePosition.Y
Next
Set devReplay = CreateObject("mercury.devicereplay")
devReplay.MouseClick absx+4,absy+4,2
点击获取的鼠标位置与预期不一致,修改对象的以下属性“指定要在控件中单击的位置”
单击项目树某节点
wpfwindow("NuICT").wpfobject("wpftypename:=object","regexpwndtitle:=NuICT","devename:=StackPanel","index:=10").click
wpfwindow("NuICT").wpfobject("wpftypename:=object","regexpwndtitle:=NuICT","devename:=StackPanel","text:=XXXX").click
双击
set ctrl=DotNetFactory.CreateInstance("System.Windows.Forms.Control")
CurrentMousexPosition=ctrl.MousePosition.x
CurrentMouseyPosition=ctrl.MousePosition.y
wpfwindow("NuICT").click cint(CurrentMousexPosition),cint(CurrentMouseyPosition)
wpfwindow("NuICT").dblclick cint(CurrentMousexPosition),cint(CurrentMouseyPosition)