I am using the watir-webdriver ruby gem. It starts the browser (Chrome) and begins to load a page. The page is loading too slowly, and watir-webdriver raises a timeout error. How can I make the browser stop loading the page?
require 'watir-webdriver'
client = Selenium::WebDriver::Remote::Http::Default.new
client.timeout = 10
@browser = Watir::Browser.new :chrome, :http_client => client
sites = [
"http://google.com/",
"http://yahoo.com/",
"http://www.nst.com.my/", # => This is the SLOW site
"http://drupal.org/",
"http://www.msn.com/",
"http://stackoverflow.com/"
]
sites.each do |url|
begin
@browser.goto(url)
puts "Success #{url}"
rescue
puts "Timeout #{url}"
end
end
########## Execution result ##########
# Success http://google.com/
# Success http://yahoo.com/
# Timeout http://www.nst.com.my/
# Timeout http://drupal.org/
# Timeout http://www.msn.com/
# Timeout http://stackoverflow.com/
########## Expected result ##########
# Success http://google.com/
# Success http://yahoo.com/
# Timeout http://www.nst.com.my/
# Success http://drupal.org/
# Success http://www.msn.com/
# Success http://stackoverflow.com/
It looks like the browser doesn't respond to any other commands before it finishes loading the page. How can I force the browser to throw away the page it is loading and execute the next command?
UPDATED
I have found an interesting capability flag loadAsync http://src.chromium.org/svn/trunk/src/chrome/test/webdriver/webdriver_capabilities_parser.cc Maybe it can be useful for solving this problem? I don't understand yet how to make watir (webdriver) to set this when starting the chromedriver. This flag was introduced here http://codereview.chromium.org/7582005/