0
votes

As far as searching goes, i was unable to find an up-to-date list of supported browsers for watir.

I've just upgraded firefox to version 18, and while at it, also update the watir-webdriver version to it's latest (by using gem update watir-webdriver).

So far i've encountered one issue, that i cant seem to find a solution for.

When i try to check if an element exist, lets say by using $browser.a(:href, "#{$url}/admin/").exists? (The $url variable is defined to the main url of my testing server, so it's not the problem. Furthermore, even when i replace the variable with the actual address, i still encounter the same issue), I always get a timeout error when the element does not exists.

When the element does exists, i will get an instant response of true. So the timeout issue only happens when the element does not exists.

So my questions are:

  1. Is there a way to make the .exists? method work?
  2. Does anyone know any other issues like that with the latest version of Firefox(V. 18)?
  3. I would really appreciate if someone can point me to an updated list of watir supported browsers. Preferably a list that is being updated on a regular basis.

P.S, I did see that someone posted a question about the present? method, i have no idea of it's related, but nonetheless, i still have no solution. I'd hate to downgrade to a previous version of ff.

Thanks a bunch to anyone who will be willing to help,

Kind regards, Asaf.

1
What is the exact text of the error you get in the stacktrace? What is the version of Selenium-webdriver that you have installed? When you test against a browser other than Firefox does your script throw the same timeout error?Abe Heward
Actually Abe, You solved the problem for me. i just needed to update the selenium-webdriver gem(which, in my foolishness, i forgot to do) and everything seems to be working as it should. Thanks a lot!Asaf Blum

1 Answers

0
votes

I had such problems here and there and the solution was to catch the exception and re-run the piece of code that triggered this exception. Of course, I'm assuming your exception is triggered by some transient cause, possibly by a glitch in Watir.

Briefly, you could do something like this:

begin
  $browser.a(:href, "#{$url}/admin/").exists?
rescue Timeout::Error
  puts("Caught a TIMEOUT ERROR!")
  sleep(1)
  # Retry the sode that generates the esception.
  retry
end

That's the simplest form. You could also make sure not to lock up yourself in an infinite loop by doing something like:

retries_left = 3
begin
  $browser.a(:href, "#{$url}/admin/").exists?
rescue Timeout::Error
  puts("Caught a TIMEOUT ERROR!")

  # You may want to wait for a while before retrying.
  sleep(1)

  # Retry the code that generates the exception.
  retries_left -= 1
  retry if retries_left > 0

  # No more retries left - time to bail out! Re-raise the exception.
  raise
end

You could improve this a bit by abstracting this exception handling code into a test helper method that accepts blocks and use it in a much more cleaner way, without repeating yourself, like:

handle_transient_exceptions {
  $browser.a(:href, "#{$url}/admin/").exists?
}

But that's not what you asked about. :)

Referring to your third question, I can say that watir-webdriver supports the latest Chrome, Firefox and IE9 pretty well. I'm working with these browsers currently and haven't spotted any blocking issues yet.