Reputation: 315
I have been getting a Timeout error ever since I started developing my tests. At first I thought it was related to the efficiency of my xpaths but after seeing the test pass quickly numerous times I don't think it is related to the selectors. The error randomly occurs and often when it does it occurs multiple times within a feature. I need to fix or at least understand what this problem is.
An example of a step definition:
When /^I navigate to "(.*)"$/ do |webpage|
navigate_to(webpage)
end
This is the error I get:
Timeout::Error (Timeout::Error)
/usr/lib/ruby/1.9.1/net/protocol.rb:146:in `rescue in rbuf_fill'
/usr/lib/ruby/1.9.1/net/protocol.rb:140:in `rbuf_fill'
/usr/lib/ruby/1.9.1/net/protocol.rb:122:in `readuntil'
/usr/lib/ruby/1.9.1/net/protocol.rb:132:in `readline'
/usr/lib/ruby/1.9.1/net/http.rb:2562:in `read_status_line'
/usr/lib/ruby/1.9.1/net/http.rb:2551:in `read_new'
/usr/lib/ruby/1.9.1/net/http.rb:1319:in `block in transport_request'
/usr/lib/ruby/1.9.1/net/http.rb:1316:in `catch'
/usr/lib/ruby/1.9.1/net/http.rb:1316:in `transport_request'
/usr/lib/ruby/1.9.1/net/http.rb:1293:in `request'
/usr/lib/ruby/1.9.1/net/http.rb:1286:in `block in request'
/usr/lib/ruby/1.9.1/net/http.rb:745:in `start'
/usr/lib/ruby/1.9.1/net/http.rb:1284:in `request'
./features/support/env.rb:88:in `block in get_page_url'
The env.rb :
require 'selenium-webdriver'
require 'rubygems'
require 'nokogiri'
require 'rspec'
require 'rspec/expectations'
require 'httpclient'
require 'fileutils.rb'
require 'pathname'
$driver = Selenium::WebDriver.for :ie
#accept_next_alert = true
$driver.manage.timeouts.implicit_wait = 300
$driver.manage.timeouts.script_timeout = 300
$driver.manage.timeouts.page_load = 300
#verification_errors = []
AfterStep do
sleep 5
end
at_exit do
$driver.close
end
I have gone through numerous questions about this very same topic and none seem to have an answer that works, if an answer at all.
Similar issue. I have tried the solutions provided here but my error still persist https://www.ruby-forum.com/topic/4414675
I have tried adding explicit waits as such: http://docs.seleniumhq.org/docs/04_webdriver_advanced.jsp
I need to get this issue sorted out so please ask questions if I wasn't clear on anything.
Here is a list of installed gems:
archive-tar-minitar (0.5.2)
bigdecimal (1.1.0)
builder (3.2.0)
bundler (1.3.5)
childprocess (0.3.9)
columnize (0.3.6)
commonwatir (4.0.0)
cucumber (1.2.3)
debugger-linecache (1.2.0)
debugger-ruby_core_source (1.2.2)
diff-lcs (1.2.1)
ffi (1.5.0, 1.0.9)
gherkin (2.11.6)
hoe (3.6.2)
httpclient (2.3.2)
io-console (0.3)
json (1.7.7)
linecache19 (0.5.12)
mime-types (1.23)
mini_magick (3.6.0)
mini_portile (0.5.0)
minitest (2.12.1, 2.5.1)
multi_json (1.7.1)
nokogiri (1.5.9)
rack (1.5.2)
rack-test (0.6.2)
rake (10.0.3, 0.9.6)
rautomation (0.9.2)
rb-readline (0.5.0)
rdoc (3.12.1)
rspec (2.13.0)
rspec-core (2.13.1)
rspec-expectations (2.13.0)
rspec-mocks (2.13.0)
ruby-debug-base19 (0.11.25)
ruby-debug19 (0.11.6)
ruby_core_source (0.1.5)
rubygems-update (2.0.3)
rubyzip (0.9.9)
s4t-utils (1.0.4)
selenium-webdriver (2.33.0, 2.31.0)
subexec (0.2.3)
user-choices (1.1.6.1)
watir (4.0.2)
watir-classic (3.7.0)
watir-webdriver (0.6.2)
websocket (1.0.7)
win32-api (1.4.8)
win32-process (0.7.2)
win32screenshot (1.0.8)
windows-api (0.4.2)
windows-pr (1.2.2)
xml-simple (1.1.2)
xpath (2.0.0)
Upvotes: 11
Views: 13866
Reputation: 564
I'm using selenium for scraping and not for test right now and I'm dealing with that something like this:
browser_name = :chrome
http_client = Selenium::WebDriver::Remote::Http::Default.new(open_timeout: 5.minutes, read_timeout: 5.minutes)
@browser = Watir::Browser.new browser_name, http_client: http_client
Upvotes: 0
Reputation: 31
I encountered this error with watir-webdriver, in my case I was attempting to visit:
@browser.goto "localhost:3000/#/login"
When I should have been visiting:
@browser.goto "http://localhost:3000/#/login"
Strangely enough my first scenario calling this method worked but when attempting to navigate that same URL on my second scenario I received a stack similar trace to yours
Upvotes: 0
Reputation: 315
I have edited the env.rb since posting this and have updated that part of the question. This may not be the absolute fix but it is something I have noticed that to me- has fixed part of the problem.
I changed the timeouts in the env.rb from 300 to 20.
$driver.manage.timeouts.implicit_wait = 20
$driver.manage.timeouts.script_timeout = 20
$driver.manage.timeouts.page_load = 20
Upon doing that my test suite now executes much faster and instead of lengthy timeout errors I am getting real errors pertaining to my code (poor selector, wrong method etc).
Timeouts I used to get for simply navigating to a page have become:
Timed out waiting for page to load. (Selenium::WebDriver::Error::TimeOutError)
Which is appearing in less than 20 seconds but it may be due to the connection I have with the web page. I will be researching this error more in the near future.
If anyone tries this please let me know how it worked out for you (even if it didn't). I will keep updating this as I learn more.
Upvotes: 2
Reputation: 7225
try delete\ing cache folder located in tmp/cache in your rails application and also run 'rake assets:clean:all' at the root of your application
Upvotes: 0
Reputation: 1675
Internet Explorer has issues with xpaths more than the other browsers. I used to run into this problem using webdriver and java. Have you tried instantiating a Selector using a css selector and seeing if that helps the browser locate the element?
Upvotes: 0
Reputation: 6735
There is a discussion of this problem on Ruby
forum.
There seemed to be not fix for it as for 19 July 2013, but there is a proposal to extend the amount of time before a failure with:
driver.manage.timeouts.page_load = 300 # 5 minutes
Upvotes: 0