Re: [Wtr-general] Using Until

2007-04-05 Thread Bret Pettichord
Nicola Kennedy wrote:
> I want the code to do the following things:
> 1. Check on page for a link.
> 2. If link not there, press "Next page"
>   
> 3. If link there, click on it.
>   
> 4. When next page reached (if step 2 followed), repeat the action of looking 
> for link/clicking next.
>   
Here is one way:

def click_links ie
  unless ie.link(:url, "http://www.freeuk.com";).exists?
ie.link(:value, 'Next page').click
click_links ie
  else
ie.link(:url, "http://www.freeuk.com";).click
   end
end

___
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general


Re: [Wtr-general] Using Until

2007-04-04 Thread Paul Rogers
so my example was kind of incomplete. I really only meant it as an example. Try 
this instead.

def link_there?
  link_text = "Click Me"
  return @ie.link(:text , link_text).exists?
end 

@ie=Watir::IE.attach('www.google.com')

while 1  # add something here to stop infinite loop
  if link_there?
@ie.link(:text , link_text).click?
  else
@ie.link(:text , "Next").click
  end
end



- Original Message -
From: Nicola Kennedy <[EMAIL PROTECTED]>
Date: Wednesday, April 4, 2007 3:59 am
Subject: Re: [Wtr-general] Using Until

> I have tried the advice given by Paul (Thankyou) but am now 
> receiving an error message when I run:
> 
> 1) Error:
> test_recorded(TC_recorded):
> NoMethodError: undefined method `link' for nil:NilClass
>testnic26.rb:30:in `link_there?'
>testnic26.rb:35:in `test_recorded'
> 
> 1 tests, 0 assertions, 0 failures, 1 errors
> >Exit code: 0
> 
> 
> Please advise??
> 
> TIA
> ___
> Wtr-general mailing list
> Wtr-general@rubyforge.org
> http://rubyforge.org/mailman/listinfo/wtr-general
> 
___
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general


Re: [Wtr-general] Using Until

2007-04-04 Thread Nicola Kennedy
I have tried the advice given by Paul (Thankyou) but am now receiving an error 
message when I run:

 1) Error:
test_recorded(TC_recorded):
NoMethodError: undefined method `link' for nil:NilClass
testnic26.rb:30:in `link_there?'
testnic26.rb:35:in `test_recorded'

1 tests, 0 assertions, 0 failures, 1 errors
>Exit code: 0


Please advise??

TIA
___
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general


Re: [Wtr-general] Using Until

2007-04-03 Thread Paul Rogers
isnt Jeffs code kind of over kill for this?


def link_there?
  link_text = "Click Me"
  return @ie.link(:text , link_text).exists?
end  


while 1  # add something here to stop infinite loop
  if link_there?
@ie.link(:text , link_text).click?
  else
@ie.link(:text , "Next").click
  end
end



- Original Message -
From: Chris McMahon <[EMAIL PROTECTED]>
Date: Tuesday, April 3, 2007 9:04 am
Subject: Re: [Wtr-general] Using Until

> Aha, so you want to click Google's "Next" button?  Take a look at
> this, it might give you some ideas:
> http://testingjeff.wordpress.com/2007/01/27/creating-methods-on-
> the-flyand-bugs-in-google-phonebook/
> 
> Also, if you are unsure how to address a particular page element, take
> a look at the "unittests" folder in the watir directory.  It will be
> in C:/ruby/lib/ruby... somewhere, depending on whether you did a gem
> install or used the one-click installer.
> 
> On 4/3/07, Nicola Kennedy <[EMAIL PROTECTED]> wrote:
> > Sorry, probably my fault for not being clear about how new I am 
> to this.
> >
> > I want the code to do the following things:
> > 1. Check on page for a link.
> > 2. If link not there, press "Next page"
> > 3. If link there, click on it.
> > 4. When next page reached (if step 2 followed), repeat the 
> action of looking for link/clicking next.
> >
> > Am playing around with code, and have come up with following:
> >
> > link = ie.link(:url, "http://www.freeuk.com";)
> > until link.exists
> > 
> ie.goto("http://www.google.co.uk/search?q=freeuk&hl=en&start=10&sa=N";)>
> > if link.exists = true
> >   ie.goto(link)
> > end
> >
> > Am totally aware that this will not work, but it may give my 
> helpers more idea of the details I want!!
> >
> > Thankyou all in advance, and please help!
> > ___
> > Wtr-general mailing list
> > Wtr-general@rubyforge.org
> > http://rubyforge.org/mailman/listinfo/wtr-general
> >
> ___
> Wtr-general mailing list
> Wtr-general@rubyforge.org
> http://rubyforge.org/mailman/listinfo/wtr-general
> 
___
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general


Re: [Wtr-general] Using Until

2007-04-03 Thread Chris McMahon
Aha, so you want to click Google's "Next" button?  Take a look at
this, it might give you some ideas:
http://testingjeff.wordpress.com/2007/01/27/creating-methods-on-the-flyand-bugs-in-google-phonebook/

Also, if you are unsure how to address a particular page element, take
a look at the "unittests" folder in the watir directory.  It will be
in C:/ruby/lib/ruby... somewhere, depending on whether you did a gem
install or used the one-click installer.

On 4/3/07, Nicola Kennedy <[EMAIL PROTECTED]> wrote:
> Sorry, probably my fault for not being clear about how new I am to this.
>
> I want the code to do the following things:
> 1. Check on page for a link.
> 2. If link not there, press "Next page"
> 3. If link there, click on it.
> 4. When next page reached (if step 2 followed), repeat the action of looking 
> for link/clicking next.
>
> Am playing around with code, and have come up with following:
>
> link = ie.link(:url, "http://www.freeuk.com";)
> until link.exists
> ie.goto("http://www.google.co.uk/search?q=freeuk&hl=en&start=10&sa=N";)
>
> if link.exists = true
>   ie.goto(link)
> end
>
> Am totally aware that this will not work, but it may give my helpers more 
> idea of the details I want!!
>
> Thankyou all in advance, and please help!
> ___
> Wtr-general mailing list
> Wtr-general@rubyforge.org
> http://rubyforge.org/mailman/listinfo/wtr-general
>
___
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general


Re: [Wtr-general] Using Until

2007-04-03 Thread Nicola Kennedy
Sorry, probably my fault for not being clear about how new I am to this.

I want the code to do the following things:
1. Check on page for a link.
2. If link not there, press "Next page"
3. If link there, click on it.
4. When next page reached (if step 2 followed), repeat the action of looking 
for link/clicking next.

Am playing around with code, and have come up with following:

link = ie.link(:url, "http://www.freeuk.com";)
until link.exists
ie.goto("http://www.google.co.uk/search?q=freeuk&hl=en&start=10&sa=N";)

if link.exists = true
  ie.goto(link)
end

Am totally aware that this will not work, but it may give my helpers more idea 
of the details I want!!

Thankyou all in advance, and please help!
___
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general


Re: [Wtr-general] Using Until

2007-04-03 Thread John Lolis
I'm not sure how new 'wait_until' is, but if you have it do

wait_until(time_to_wait_in_seconds){ $ie.element(:type,'value').exists? }
___
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general


Re: [Wtr-general] Using Until

2007-04-03 Thread Chris McMahon
> I'm trying to put a loop in a script where it checks for a link on a page, if 
> the link isn't there, it clicks on the next page button, looks for the link 
> again, and the process repeats until it finds the link, and then clicks on it.

It'd be easier to help if you would post a) the HTML involved and b)
the Watir code you've tried so far.
___
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general


[Wtr-general] Using Until

2007-04-03 Thread Nicola Kennedy
Hi,

Am v new to Watir/Ruby, so probably a simple question for someone.
I'm trying to put a loop in a script where it checks for a link on a page, if 
the link isn't there, it clicks on the next page button, looks for the link 
again, and the process repeats until it finds the link, and then clicks on it.

Can anyone help?

TIA
___
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general