QTP三种不同的objectIndentification

QTP三种对象识别方法:

1.ObjectRepository 对象库

利用SPY抓取对象,放入QTP对象库。

2.ProgrammaticDescription 描述编程对象

Arr = Array("One","Two","Three")
For i = LBound(Arr) to UBound(Arr)
	Browser("title:=.*”).Page("title:=.*").WebButton("name:="&Arr(i)).Click
Next

3.DescriptionObject 描述对象

Set Desc = Description.Create()
Desc("html tag").Value = "button"
Desc("html tag").RegularExpression = False

'Arr = Array("One","Two","Three")
'For i = LBound(Arr) to UBound(Arr)
' Desc("name").Value = Arr(i)
'	Browser("title:=.*”).Page("title:=.*").WebButton(Desc).Click
'Next

Set Buttons = Browser("title:=.*”).Page("title:=.*").ChildObjects(Desc)
For i = 0 to Buttons.Count-1
  Buttons(i).Click
Next

例子:在百度上实验吧

A.ProgrammaticDescription 

SystemUtil.Run "iexplore.exe","www.baidu.com"
Browser("name:=百度一下,你就知道").Page("title:=百度一下,你就知道").WebEdit("html id:=kw1").Set "testdao"
Browser("name:=百度一下,你就知道.*").Page("title:=百度一下,你就知道").WebButton("html id:=su1").Click
B.DescriptionObject 
SystemUtil.Run "iexplore.exe","www.baidu.com"
oDesc("html id").Value = "kw1"
Browser("name:=百度一下,你就知道").Page("title:=百度一下,你就知道").WebEdit(oDesc).Set "testdao"



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值