[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

ie.link(:text, "Next").click

michael

12/5/2006 9:56:00 PM

I am navigating through web page using WATIR..

and as you know, many web pages has "Next" link that allows us to go to
the next page by clicking this "Next" link.

Now when the page reaches the last page, although "Next" is present,
but it is no longer a link.

At this point, if my code still goes to:

ie.link(:text, "Next").click

then I get the error message..

Is there anyway I can have WATIR check whether "Next" is link or not,
and if it is a link, then go to

ie.link(:text, "Next").click,

and if it is just plain text, do not go to ie.link(:text,
"Next").click??

thanks.

4 Answers

Paul Lutus

12/5/2006 10:29:00 PM

0

curious wrote:

> I am navigating through web page using WATIR..
>
> and as you know, many web pages has "Next" link that allows us to go to
> the next page by clicking this "Next" link.
>
> Now when the page reaches the last page, although "Next" is present,
> but it is no longer a link.
>
> At this point, if my code still goes to:
>
> ie.link(:text, "Next").click
>
> then I get the error message..

As others have replied to one of your other posts on this topic, why not
trap the error using "rescue", and move on from there?

--
Paul Lutus
http://www.ara...

michael

12/5/2006 10:55:00 PM

0

could you please tell me how I can trap the error in 'rescue'..

thanks.


Paul Lutus wrote:
> curious wrote:
>
> > I am navigating through web page using WATIR..
> >
> > and as you know, many web pages has "Next" link that allows us to go to
> > the next page by clicking this "Next" link.
> >
> > Now when the page reaches the last page, although "Next" is present,
> > but it is no longer a link.
> >
> > At this point, if my code still goes to:
> >
> > ie.link(:text, "Next").click
> >
> > then I get the error message..
>
> As others have replied to one of your other posts on this topic, why not
> trap the error using "rescue", and move on from there?
>
> --
> Paul Lutus
> http://www.ara...

Paul Lutus

12/6/2006 2:26:00 AM

0

curious wrote:

> could you please tell me how I can trap the error in 'rescue'..
>

Like this:

begin
# error-creating code here
rescue
# error-handling cede here
end

Working example:

-------------------------------------

#!/usr/bin/ruby -w

begin
x = 1/0
rescue Exception => e
puts "trapped error: " + e
end

-------------------------------------

Output:

trapped error: divided by 0

--
Paul Lutus
http://www.ara...

bpettichord

12/6/2006 2:53:00 AM

0

> Is there anyway I can have WATIR check whether "Next" is link or not,
> and if it is a link, then go to
>
> ie.link(:text, "Next").click,
>
> and if it is just plain text, do not go to ie.link(:text,
> "Next").click??

if ie.link(:text, "Next").exists?
ie.link(:text, "Next").click
end