Watir: links with similar text in a page. How to access?

M

Mandeep Baruah

Hi All,

I need Help!
In a page I am having two section(windows and linux) with has some
installation instructions. This "Installation instruction" text link
which calls some javascript functions are placed twice in the page (once
under Windows and once under linux).
With the command "ie.link:)text, /Installation instruction/).click" I am
only able to click the first occurance of the text, under windows. How
to click the second instance of the same text(i.e, Installation
instruction) link, under linux?.

Thanks in advance,
Mandeep
 
S

Sarcar, Shourya C (GE Healthcare)

-----Original Message-----
From: (e-mail address removed) [mailto:[email protected]]=20
Sent: Monday, November 10, 2008 4:13 PM
To: ruby-talk ML
Subject: Watir: links with similar text in a page. How to access?
=20
Hi All,
=20
I need Help!
In a page I am having two section(windows and linux) with has=20
some installation instructions. This "Installation=20
instruction" text link which calls some javascript functions=20
are placed twice in the page (once under Windows and once=20
under linux).
With the command "ie.link:)text, /Installation=20
instruction/).click" I am only able to click the first=20
occurance of the text, under windows. How to click the second=20
instance of the same text(i.e, Installation
instruction) link, under linux?.
=20

Maybe if you send the HTML, more people can help.=20
The general idea is that you would have to first reach an enclosing
element (like a div or a frame) and then search in that constraint.
 
S

Sarcar, Shourya C (GE Healthcare)

=20
-----Original Message-----
From: (e-mail address removed) [mailto:[email protected]]=20
Sent: Monday, November 10, 2008 6:00 PM
To: ruby-talk ML
Subject: Re: Watir: links with similar text in a page. How to access?
=20
Attaching the portion of HTML that concerns. As described, I=20
need to click on the second text link, "Installation instructions".
=20
Attachments:
http://www.ruby-forum.com/attachment/2910/Watir-text-link.html
=20


If you have any control over the generation of that HTML, you should
change it to be more structured.
Otherwise, a quick and dirty way would be:

ie.links.each {|link| link.click if link.text =3D~ /Installation/}
 
B

Bret Pettichord

[Note: parts of this message were removed to make it a legal post.]

ie.link:)text => /Installation instruction/, :index => 2).click

Hi All,

I need Help!
In a page I am having two section(windows and linux) with has some
installation instructions. This "Installation instruction" text link
which calls some javascript functions are placed twice in the page (once
under Windows and once under linux).
With the command "ie.link:)text, /Installation instruction/).click" I am
only able to click the first occurance of the text, under windows. How
to click the second instance of the same text(i.e, Installation
instruction) link, under linux?.

Thanks in advance,
Mandeep


--
Bret Pettichord
GTalk: (e-mail address removed)
CTO, WatirCraft LLC, http://www.watircraft.com
Lead Developer, Watir, http://wtr.rubyforge.org
Blog (Essays), http://www.io.com/~wazmo/blog
MiniBlog (Links), http://feeds.feedburner.com/bretshotlist
 
M

Mandeep Baruah

Bret said:
ie.link:)text => /Installation instruction/, :index => 2).click

Thanks Bret, that worked and I was looking for that exactly.
Thanks, Shourya for your your time and help.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top