I am trying to print the name of all the links present on a page. I have written the below code-->
SystemUtil.Run "Chrome.exe","www.timesofindia.com"
Dim obj, objects,objectnames,i
Set obj = Description.Create
obj("micclass").value = "Link"
objects = Browser("micclass:=browser").Page("micclass:=Page").ChildObjects(obj)
MsgBox Err.number
For i = 0 To obj.Count-1 Step 1
childnames = objects.getROProperty("innertext")
print childnames(i)
Next
I am getting general run error in line objects = Browser("micclass:=browser").Page("micclass:=Page").ChildObjects(obj)
The line MsgBox Err.number
gives error number -2147467259
I tried to find out the cause with error number--2147467259 but didn't get any relevant answer. Please help.
There are several things wrong with your script
Set
objects since this is an objectFor
loop you should be looping onobjects.count
notobj.count
For
body you should useobjects(i).GetROProperty
(you forgot to index withi
)Print
statement you're indexing intochildnames
for no reasonAfter making these changes the script works for me but it's a bit slow, if you're still facing problems it may be that UFT times out while waiting for all the links to show up. If this is the case you can separate the query into several queries (for example where the
innertext
starts with each letter of the alphabet) and run them one after the other.