Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>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.</p> <p>Briefly, you could do something like this:</p> <pre><code>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 </code></pre> <p>That's the simplest form. You could also make sure not to lock up yourself in an infinite loop by doing something like:</p> <pre><code>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 &gt; 0 # No more retries left - time to bail out! Re-raise the exception. raise end </code></pre> <p>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:</p> <pre><code>handle_transient_exceptions { $browser.a(:href, "#{$url}/admin/").exists? } </code></pre> <p>But that's not what you asked about. :)</p> <p>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.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload