I've been looking over the forum, the manual and Tarun's DP in QTP doc. and feel like I must be missing something. I have a simple script where I am trying to find all the links on the page and msgbox the name or innertext of each:
<font class="small">Code:</font><hr /><pre> Set Obj = Description.Create
Obj("micclass").Value = "Link"
Set Collection = Browser("micclass:=Browser").Page("micclass:=Page" ).ChildObjects(Obj)
For each singleLink in Collection
forDisplay = singleLink.Name
Next </pre><hr />
I thought that all the description types would be a part of the collection I created am I wrong in thinking this?
I get this error, "Object doesn't support this property or method" on "For each singleLink in Collection"
Can someone help me understand why this doesn't work and how to make it work?
A good rule of thumb is to never measure with your thumb.
<font class="small">Code:</font><hr /><pre>Do Until Not Browser().Page().Link("index:=" & indexcount).Exist(1)
Msgbox(Browser().Page().Link("index:=" & indexcount).GetROProperty("name") & " / " & Browser().Page().Link("index:=" & indexcount).GetROProperty("innertext"))
indexcount = indexcount + 1
Hey TReddy, I was able to use your code also, but also wanted to click a random link from the collection. I wasn't sure how to do that. I created the following which allowed me to randomly select an item count( see second ex below) but wanted to click a randomly selected link from the list:
I want to combine your collection loop with a random click of a link within the collection:
Set Collection =Browser("Search Page").Page("Search Page").ChildObjects(randomLinks)
For i = 0 To Collection.Count-1
Public Function getRandomLink(Collection)
getItemsCount_Links = Collection
max = getItemsCount_Links
randomN =Int((max - min + 1) * Rnd + min)
msgbox "randomN= " & randomN
// I know the click event below won't work as it can't click //a number
Browser("Search Page").Page("Search Page").Link(randomN).Click