'QTP描述性编程之控件对象的5大方法
'1. 最普通的方法, 对象库中必须存在在对象,否则无法识别
Browser("百度一下,你就知道").Page("百度一下,你就知道").WebEdit("wd").Set "helloworld"
'2. 描述性编程
Browser("百度一下,你就知道").Page("百度一下,你就知道").WebEdit("name:=wd").Set "tester"
'3. 对象自身接口, 对象库中必须存在该对象, 否则无法识别
Browser("百度一下,你就知道").Page("百度一下,你就知道").WebEdit("wd").Object.Value = "helloworld"
'4. DOM技术
Browser("百度一下,你就知道").Page("百度一下,你就知道").Object.getElementById("kw").Value ="helloworld"
'5. childobject 结合描述性编程循环遍历获取对象
'描述对象
Set oDesc = Description.Create()
oDesc("micclass").Value = "WebEdit"
'获取webedit的数量
edit_count=Browser("百度一下,你就知道").Page("百度一下,你就知道").ChildObjects(oDesc).count
'获取子对象集合
set editobjects=Browser("百度一下,你就知道").Page("百度一下,你就知道").ChildObjects(oDesc)
For i=0 to edit_count-1
If editobjects(i).GetROProperty("name")="wd" then
editobjects(i).set "helloworld"
End If
Next