Love U Ruby <lists / ruby-forum.com> wrote:
> I am continuously getting an irritating error :
> 
> C:\Documents and Settings\rakshiar\My
> Documents\userdata\Ruby\Scripts>So.rb
> C:/Ruby193/lib/ruby/1.9.1/net/protocol.rb:146:in `rescue in rbuf_fill':
> Timeout:
> :Error (Timeout::Error)
...
> Code to handle this:
> 
> begin
>   elem = wait.until { driver.title == "Condition View Page"}
>   driver.find_element(:name,'btnDone').click
> rescue Timeout::Error,Selenium::WebDriver::Error::NoSuchElementError => e
>   retry
> end
> 
> But no luck. What should I do? Why the error is not being rescued? What
> should I fix in my code?

Can't really say for sure there....

Since we obviously can't see line numbers, are you sure that rescue is
at line 146? Do double check.

Something else to try, is to rescue all exceptions and check the class
of the exception without the retry.

    begin
      ..
    rescue Exception => e
      puts "Exception #{e.class} : #{e}"
      raise e
    end

Incidently, just putting retry inside rescue could result in an infinite
loop. Best to bound it with a counter.