On Wednesday, March 27, 2013 7:13:57 AM UTC-7, [email protected] wrote:
> Hi Folks,
>
> The title pretty much says it all. After I click a button to load a form I
> get the above error. My code:
>
> browser = Watir::Browser.new :ie
> browser.driver.manage.timeouts.implicit_wait = 360
> browser.goto 'http://myform.html'
> browser.text_field(:name => 'EmpNumber').set empnum
> browser.text_field(:name => 'LastName').set lastName
> browser.button(:value => 'Load Form').click
> browser.button(:value => 'Load Form').wait_while_present
>
> This still timesout before 6 minutes ... So I don;t know what I'm doing
> wrong.
>
> Before you ask, yes, I've googled and searched this list and stack
> overflow was well :)
>
> Thanks,
> Fabian
>
Setting the implicit wait in webdriver means that it will always wait up to
the allotted time for something to appear.. I think even during something
like .wait_while_present which is using this code
44
45
46
47
48
49
50
51
52
53
# File 'lib/watir-webdriver/wait.rb', line 44
def while(timeout = 30, message = nil, &block)
end_time = ::Time.now + timeout
until ::Time.now > end_time
return unless yield(self)
sleep INTERVAL
end
raise TimeoutError, message_for(timeout, message)end
I think what is happening is that at the webdriver level you've told it in
effect "when I ask you to do anything with an element, if you don't find it
then wait this long for it to appear before telling me that it is not
there.
The code above is basically calling to webdriver and saying 'hey, is this
thing there?" initially the answer is yes, so webdriver responds right
away and the watir code sleeps the interval and checks again. The first
time the object is NOT there, and we ask it "hey is this thing there" it
dutifully waits 360 seconds like you told it, before reporting back "un
yeah, I didn't find it. Which is pretty much what you don't want happening
at that point..
This is one reason why a large value on an implicit wait is generally not a
good idea, EVERY action in your code will wait up to that long for the
element to appear, that means if there is a problem on a page, the scripts
will wait like 6 minutes before reporting something like element not found.
If you feel you want to add a few seconds by default for things to appear,
that's not so bad, use a value like 3 or 5 or something, but do not use
this as a way to manage where you have just a few places in your site with
long waits.
I think you'd be a lot better off to do something like this
browser = Watir::Browser.new :ie
browser.goto 'http://myform.html'
browser.text_field(:name => 'EmpNumber').when_present.set empnum
browser.text_field(:name => 'LastName').set lastName
browser.button(:value => 'Load Form').click
browser.button(:value => 'Load Form').wait_while_present(timeout=360)
--
--
Before posting, please read http://watir.com/support. In short: search before
you ask, be nice.
[email protected]
http://groups.google.com/group/watir-general
[email protected]
---
You received this message because you are subscribed to the Google Groups
"Watir General" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.