用QTP的描述性编程高亮显示任意对象
上一篇 /
下一篇 2013-06-15 11:05:00
这里运用描述性编程实现高亮显示计算器中的0到9的按钮对象。把以下代码拷到QTP中,点“运行”,看看效果。注:本程序以windows XP下的计算器演示,若使用windows 2000的计算器无效。SystemUtil.Run "C:\WINDOWS\system32\calc.exe","","C:\WINDOWS\system32","open"For i =0 to 9HighlightAll Window("regexpwndclass:=SciCalc").WinButton("text:=" & cstr(i) )NextSub HighlightAll(TestObject) Dim Parent, Desc, Props, PropsCount, MaxIndex, i, Objs If IsEmpty(TestObject.GetTOProperty("parent")) Then Set Parent = Desktop Else Set Parent = TestObject.GetTOProperty("parent") End If Set Desc = Description.Create Set Props = TestObject.GetTOProperties PropsCount = Props.Count - 1 For i = 0 to PropsCount Desc(Props(i).Name).Value = Props(i).Value Next Set bjs = Parent.ChildObjects(Desc) MaxIndex= Objs.Count - 1 For i = 0 to MaxIndex Objs.Item(i).Highlight Next End Sub
收藏
举报
TAG: