[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

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

Mandeep Baruah

11/10/2008 10:43:00 AM

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
--
Posted via http://www.ruby-....

5 Answers

Sarcar, Shourya C (GE Healthcare)

11/10/2008 12:07:00 PM

0



> -----Original Message-----
> From: mbaruah@spikesource.com [mailto:mbaruah@spikesource.com]=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.

Mandeep Baruah

11/10/2008 12:30:00 PM

0

Sarcar, Shourya C (GE Healthcare) wrote:
>> 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?.
>>
>
> Maybe if you send the HTML, more people can help.
> 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.

Attaching the portion of HTML that concerns. As described, I need to
click on the second text link, "Installation instructions".

Attachments:
http://www.ruby-...attachment/2910/Watir-text...

--
Posted via http://www.ruby-....

Sarcar, Shourya C (GE Healthcare)

11/10/2008 2:28:00 PM

0

=20

> -----Original Message-----
> From: mbaruah@spikesource.com [mailto:mbaruah@spikesource.com]=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...
>=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/}

Bret Pettichord

11/10/2008 3:25:00 PM

0

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

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

On Mon, Nov 10, 2008 at 4:43 AM, Mandeep Baruah <mbaruah@spikesource.com>wrote:

> 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
> --
> Posted via http://www.ruby-....
>
>


--
Bret Pettichord
GTalk: bpettichord@gmail.com
CTO, WatirCraft LLC, http://www.wati...
Lead Developer, Watir, http://wtr.rub...
Blog (Essays), http://www.io.com/~...
MiniBlog (Links), http://feeds.feedburner.com/br...

Mandeep Baruah

11/11/2008 6:27:00 AM

0

Bret Pettichord wrote:
> 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.
--
Posted via http://www.ruby-....