|
各位好,我是刚使用QTP的新手,最近给一个问题困惑了好久,想在此请教一下.
我想使用QTP实现遍历页面中的WebElement对象,并访问他们的innertext值.可是,一直都不能成功.
相同的方法,我把对象改成link则能够成功,请问,是不是WebElement对象不能够如此用?
Link代码如下:
- systemutil.Run "IEXPLORE","http://www.baidu.com"
- Set all_Link = Description.Create()
- all_Link("micClass").value="Link"
- Set all_Links = Browser("micClass:=Browser").Page("micClass:=Page").ChildObjects(all_Link)
- For i = 0 to all_Links.count - 1
- Set Link_Object = all_Links.item(i)
- 'msgbox Link_Object.GetROProperty("innertext")
- Char =Char & Link_Object.GetROProperty("innertext") & vbCrLf
- Next
- msgbox Char
复制代码 WebElement代码如下:
- systemutil.Run "IEXPLORE","http://www.baidu.com/more/"
- 'WebElement
- Set all_WebElement = Description.Create()
- all_WebElement("micClass").value="WebElement"
- Set all_WebElements = Browser("micClass:=Browser").Page("micClass:=Page").ChildObjects(all_WebElement)
- For i = 0 to all_WebElements.count - 1
- Set WebElement_Object = all_WebElements.item(i)
- msgbox WebElement_Object.GetROProperty("innertext")
- Char =Char & WebElement_Object.GetROProperty("innertext") & vbCrLf
- Next
- msgbox Char
复制代码 错误提示如附件:
|
|