Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Timeout Errors when running tests Cucumber/Watir

I was hoping someone could help me with a problem I am encountering when running my cucumber tests.

I receive the following error:

  Timeout::Error (Timeout::Error)
      C:/Ruby193/lib/ruby/1.9.1/net/protocol.rb:146:in `rescue in rbuf_fill'
      C:/Ruby193/lib/ruby/1.9.1/net/protocol.rb:140:in `rbuf_fill'
      C:/Ruby193/lib/ruby/1.9.1/net/protocol.rb:122:in `readuntil'
      C:/Ruby193/lib/ruby/1.9.1/net/protocol.rb:132:in `readline'
      C:/Ruby193/lib/ruby/1.9.1/net/http.rb:2562:in `read_status_line'
      C:/Ruby193/lib/ruby/1.9.1/net/http.rb:2551:in `read_new'
      C:/Ruby193/lib/ruby/1.9.1/net/http.rb:1319:in `block in transport_request'
      C:/Ruby193/lib/ruby/1.9.1/net/http.rb:1316:in `catch'
      C:/Ruby193/lib/ruby/1.9.1/net/http.rb:1316:in `transport_request'
      C:/Ruby193/lib/ruby/1.9.1/net/http.rb:1293:in `request'
      C:/Ruby193/lib/ruby/1.9.1/net/http.rb:1286:in `block in request'
      C:/Ruby193/lib/ruby/1.9.1/net/http.rb:745:in `start'
      C:/Ruby193/lib/ruby/1.9.1/net/http.rb:1284:in `request'
      C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.25.0/lib/selenium/webdriver/remote/http/default.rb:82:in `response_for'
      C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.25.0/lib/selenium/webdriver/remote/http/default.rb:38:in `request'
      C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.25.0/lib/selenium/webdriver/remote/http/common.rb:40:in `call'
      C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.25.0/lib/selenium/webdriver/remote/bridge.rb:598:in `raw_execute'
      C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.25.0/lib/selenium/webdriver/remote/bridge.rb:576:in `execute'
      C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.25.0/lib/selenium/webdriver/remote/bridge.rb:242:in `getScreenshot'
      C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.25.0/lib/selenium/webdriver/common/driver_extensions/takes_screenshot.rb:34:in `screenshot_as'
      C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.25.0/lib/selenium/webdriver/common/driver_extensions/takes_screenshot.rb:18:in `block in save_screenshot'
      C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.25.0/lib/selenium/webdriver/common/driver_extensions/takes_screenshot.rb:18:in `open'
      C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.25.0/lib/selenium/webdriver/common/driver_extensions/takes_screenshot.rb:18:in `save_screenshot'

Does anybody have any idea what causes this?

This error occurs randomly during my test suite execution. In the suite I would have something like 150 scenarios and I have seen this error occur at different stages. For example could happen at scenario 50 or scenarios 100. I run my tests via a rake file from Jenkins or via the cmd window but the error occurs if I use either method.

Our test sites here can be a little bit flakey and an odd timeout here and there is probably to be expected. However once this error starts occurring all other tests that follow on from the test the error occurred on will have the same problem. None of my scenarios are dependent on each other. Each scenario generally starts with a step I go to the homepage - in this step in my .rb file I have @browser.cookies.clear included so there should be no data remaining from the previous scenario.

Has anyone else encountered this and if so what steps did you take to sort it?

like image 234
user1523236 Avatar asked Aug 17 '12 11:08

user1523236


1 Answers

I had the same issue recently. As I can't see your code, I'm not sure what exactly is going on, but using some type of rescue should work. My issue was using a headless browser and rescuing...

  begin
    browser = Watir::Browser.start site
  rescue Timeout::Error
    puts "Timeout Rescue"
  retry

Let me know if this works.

like image 127
Carey McIntyre Avatar answered Nov 12 '22 23:11

Carey McIntyre