Hi!
You could build an array of all the links and then get the index:
link_text = Array.new
browser.links.each do |link|
link_text.push(link.text)
end
link_index = link_text.index('My link text').index
To click on a link that precedes some text, you can use :beforeText.
On the current Google page, for example:
browser.link(:beforeText, 'survivors of the Haiti
earthquake.").click
You can also use :afterText, if necessary.
Hope this helps!
-Tiffany
On Jan 13, 2:20 pm, xguarder <[email protected]> wrote:
> I was wondering if someone could inform me on how to do the following:
>
> 1. Retrieve link index number of a link. For instance, I know I can
> find the link using ie.link(:text, "LinkText"), and I can also find
> out the index number via irb. However, I want to be able to assign the
> index number of that particular link to a variable on the fly.
>
> 2. Is it possible to click on a link that immediately precedes a
> particular text?
>
> Thanks!
--
You received this message because you are subscribed to the Google Groups
"Watir General" group.
To post to this group, send email to [email protected]
Before posting, please read the following guidelines:
http://wiki.openqa.org/display/WTR/Support
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/watir-general