Monday, May 3, 2010

Write a script to find out the number of links displayed in a web page

Set linkObj=description.Create
linkObj("micclass").value="link"

Set linkchildObjs=browser("xxx").Page("yyy").ChildObjects(linkObj)

childCount=linkchildObjs.count

For i=0 to childCount-1
msgbox linkchildObjs(i).getROProperty("innertext")
Next

If you want to click on the last link on that page:
browser("xxx").Page("yyy").link("index:="&childCount-1).click

Set linkObj=nothing


Following is the code to check all checkboxes:
Set cbObj=description.Create
cbObj("html tag").value="INPUT"
cbObj("type").value="checkbox"

set childObj=browser("xxx").Page("yyy").ChildObjects(cbObj)

For i=0 to childObj.count-1
childObi(1).set "ON"
Next

No comments: