# \`rescue in rbuf\_fill': Timeout: :Error (Timeout::Error) - selenium-webdriver

**URL:** <https://rubytalk.org/t/rescue-in-rbuf-fill-timeout-error-timeout-error-selenium-webdriver/68016>\
**Category:** ruby-talk\
**Created:** [11 June 2013 05:24 UTC](https://rubytalk.org/t/rescue-in-rbuf-fill-timeout-error-timeout-error-selenium-webdriver/68016 "2013-06-11T05:24:45Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![7stud2](https://avatars.discourse-cdn.com/v4/letter/7/9de053/32.png) [@7stud2](https://rubytalk.org/u/7stud2)\
**Post date:** [11 June 2013 05:24 UTC](https://rubytalk.org/t/rescue-in-rbuf-fill-timeout-error-timeout-error-selenium-webdriver/68016/1 "2013-06-11T05:24:45Z")

</div>

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)  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from C:/Ruby193/lib/ruby/1.9.1/net/protocol.rb:140:in  
`rbuf\_fill'  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from C:/Ruby193/lib/ruby/1.9.1/net/protocol.rb:122:in  
`readuntil'  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from C:/Ruby193/lib/ruby/1.9.1/net/protocol.rb:132:in `readline'  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from C:/Ruby193/lib/ruby/1.9.1/net/http.rb:2562:in  
`read\_status\_line'  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from C:/Ruby193/lib/ruby/1.9.1/net/http.rb:2551:in `read\_new'  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from C:/Ruby193/lib/ruby/1.9.1/net/http.rb:1319:in `block in  
transport\_r  
equest'  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from C:/Ruby193/lib/ruby/1.9.1/net/http.rb:1316:in `catch'  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from C:/Ruby193/lib/ruby/1.9.1/net/http.rb:1316:in  
`transport\_request'  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from C:/Ruby193/lib/ruby/1.9.1/net/http.rb:1293:in `request'  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from C:/Ruby193/lib/ruby/1.9.1/net/http.rb:1286:in `block in  
request'  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from C:/Ruby193/lib/ruby/1.9.1/net/http.rb:745:in `start'  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from C:/Ruby193/lib/ruby/1.9.1/net/http.rb:1284:in `request'  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from  
C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.30.0/lib/s  
elenium/webdriver/remote/http/default.rb:83:in `response\_for'  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from  
C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.30.0/lib/s  
elenium/webdriver/remote/http/default.rb:39:in `request'  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from  
C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.30.0/lib/s  
elenium/webdriver/remote/http/common.rb:40:in `call'  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from  
C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.30.0/lib/s  
elenium/webdriver/remote/bridge.rb:615:in `raw\_execute'  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from  
C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.30.0/lib/s  
elenium/webdriver/remote/bridge.rb:593:in `execute'  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from  
C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.30.0/lib/s  
elenium/webdriver/remote/bridge.rb:358:in `clickElement'  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from  
C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.30.0/lib/s  
elenium/webdriver/common/element.rb:54:in `click'  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from C:/Documents and Settings/rakshiar/My  
Documents/userdata/Ruby/Scrip  
ts/So.rb:75:in `\<main\>'

C:\Documents and Settings\rakshiar\My  
Documents\userdata\Ruby\Scripts\>gem --h  
ERROR: Invalid option: --h. See 'gem --help'.

C:\Documents and Settings\rakshiar\My Documents\userdata\Ruby\Scripts\>

Code to handle this:

begin  
&nbsp;&nbsp;elem = wait.until { driver.title == "Condition View Page"}  
&nbsp;&nbsp;driver.find\_element(:name,'btnDone').click  
rescue Timeout::Error,Selenium::WebDriver::Error::NoSuchElementError =\>  
e  
&nbsp;&nbsp;retry  
end

But no luck. What should I do? Why the error is not being rescued? What  
should I fix in my code?

Thanks

> **···**
>
> --  
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).

---

<div class="post-metadata">

**Author:** ![Tamara\_Temple1](https://avatars.discourse-cdn.com/v4/letter/t/5f9b8f/32.png) [@Tamara\_Temple1](https://rubytalk.org/u/Tamara_Temple1)\
**Post date:** [11 June 2013 06:11 UTC](https://rubytalk.org/t/rescue-in-rbuf-fill-timeout-error-timeout-error-selenium-webdriver/68016/2 "2013-06-11T06:11:27Z")

</div>

> 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  
> &nbsp;&nbsp;elem = wait.until { driver.title == "Condition View Page"}  
> &nbsp;&nbsp;driver.find\_element(:name,'btnDone').click  
> rescue Timeout::Error,Selenium::WebDriver::Error::NoSuchElementError =\> e  
> &nbsp;&nbsp;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.

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

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

> **···**
>
> Love U Ruby \<lists@ruby-forum.com\> wrote:

---

<div class="post-metadata">

**Author:** ![7stud2](https://avatars.discourse-cdn.com/v4/letter/7/9de053/32.png) [@7stud2](https://rubytalk.org/u/7stud2)\
**Post date:** [19 July 2013 15:15 UTC](https://rubytalk.org/t/rescue-in-rbuf-fill-timeout-error-timeout-error-selenium-webdriver/68016/3 "2013-07-19T15:15:27Z")

</div>

I am getting the exact same error randomly in my test. I am using  
selenium-webdriver and cucumber. I am trying to tackle this problem and  
I have not seen any fix for it yet.

> **···**
>
> --  
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).

---

<div class="post-metadata">

**Author:** ![7stud2](https://avatars.discourse-cdn.com/v4/letter/7/9de053/32.png) [@7stud2](https://rubytalk.org/u/7stud2)\
**Post date:** [19 July 2013 15:55 UTC](https://rubytalk.org/t/rescue-in-rbuf-fill-timeout-error-timeout-error-selenium-webdriver/68016/4 "2013-07-19T15:55:27Z")

</div>

It's supposed to stop after a certain amount of time. Otherwise you'll  
end up with a program which waits indefinitely.

If you want to extend the amount of time before a failure:

driver.manage.timeouts.page\_load = 300 # 5 minutes

> **···**
>
> --  
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).

---

<div class="post-metadata">

**Author:** ![7stud2](https://avatars.discourse-cdn.com/v4/letter/7/9de053/32.png) [@7stud2](https://rubytalk.org/u/7stud2)\
**Post date:** [19 July 2013 18:08 UTC](https://rubytalk.org/t/rescue-in-rbuf-fill-timeout-error-timeout-error-selenium-webdriver/68016/5 "2013-07-19T18:08:51Z")

</div>

Thank you! I will try and look up what other timeouts there are and  
extend all of them. I am still getting the error but it has not occurred  
yet for navigating to a page since trying you solution

> **···**
>
> --  
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).

---

<div class="post-metadata">

**Author:** ![7stud2](https://avatars.discourse-cdn.com/v4/letter/7/9de053/32.png) [@7stud2](https://rubytalk.org/u/7stud2)\
**Post date:** [19 July 2013 18:25 UTC](https://rubytalk.org/t/rescue-in-rbuf-fill-timeout-error-timeout-error-selenium-webdriver/68016/6 "2013-07-19T18:25:50Z")

</div>

I also added

driver.manage.timeouts.read\_timeout = 500

I will update later but after executing my test suite 3 times I haven't  
seen the error yet. If/When it appears again I will update this.

> **···**
>
> --  
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).

---

<div class="post-metadata">

**Author:** ![7stud2](https://avatars.discourse-cdn.com/v4/letter/7/9de053/32.png) [@7stud2](https://rubytalk.org/u/7stud2)\
**Post date:** [19 July 2013 18:26 UTC](https://rubytalk.org/t/rescue-in-rbuf-fill-timeout-error-timeout-error-selenium-webdriver/68016/7 "2013-07-19T18:26:55Z")

</div>

This is also in combination with Joels answer.

This is what my timeouts look like

driver.manage.timeouts.implicit\_wait = 30  
driver.manage.timeouts.script\_timeout = 30  
driver.manage.timeouts.read\_timeout = 500  
driver.manage.timeouts.page\_load = 60

> **···**
>
> --  
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).
