I use watir-webdriver to automate some daily tasks, bit recently my flawlessly working script aborted at the start. When I use browser.goto "webpage" the webpage doesn't load fully, because there is a counter at the bottom of the page, and the counter service seems to be temporiraly down. Sometimes it loads, sometimes not. Otherwise all html element which I need are loaded and visible, but the page is unable to load fully, so after 30 secs I always get a tiemout error and my Ruby script terminates with this error message:
/opt/ruby1.8/lib/ruby/1.8/timeout.rb:64:in `rbuf_fill': execution expired (Timeout::Error)
from /opt/ruby1.8/lib/ruby/1.8/net/protocol.rb:134:in `rbuf_fill'
from /opt/ruby1.8/lib/ruby/1.8/net/protocol.rb:116:in `readuntil'
from /opt/ruby1.8/lib/ruby/1.8/net/protocol.rb:126:in `readline'
from /opt/ruby1.8/lib/ruby/1.8/net/http.rb:2028:in `read_status_line'
from /opt/ruby1.8/lib/ruby/1.8/net/http.rb:2017:in `read_new'
from /opt/ruby1.8/lib/ruby/1.8/net/http.rb:1051:in `request'
from /opt/ruby1.8/lib/ruby/1.8/net/http.rb:1037:in `request'
from /opt/ruby1.8/lib/ruby/1.8/net/http.rb:543:in `start'
from /opt/ruby1.8/lib/ruby/1.8/net/http.rb:1035:in `request'
from /opt/ruby1.8/lib/ruby/gems/1.8/gems/selenium-webdriver-2.25.0/lib/selenium/webdriver/remote/http/default.rb:82:in `response_for'
from /opt/ruby1.8/lib/ruby/gems/1.8/gems/selenium-webdriver-2.25.0/lib/selenium/webdriver/remote/http/default.rb:38:in `request'
from /opt/ruby1.8/lib/ruby/gems/1.8/gems/selenium-webdriver-2.25.0/lib/selenium/webdriver/remote/http/common.rb:40:in `call'
from /opt/ruby1.8/lib/ruby/gems/1.8/gems/selenium-webdriver-2.25.0/lib/selenium/webdriver/remote/bridge.rb:598:in `raw_execute'
from /opt/ruby1.8/lib/ruby/gems/1.8/gems/selenium-webdriver-2.25.0/lib/selenium/webdriver/remote/bridge.rb:576:in `execute'
from /opt/ruby1.8/lib/ruby/gems/1.8/gems/selenium-webdriver-2.25.0/lib/selenium/webdriver/remote/bridge.rb:99:in `get'
from /opt/ruby1.8/lib/ruby/gems/1.8/gems/selenium-webdriver-2.25.0/lib/selenium/webdriver/common/navigation.rb:14:in `to'
from /opt/ruby1.8/lib/ruby/gems/1.8/gems/watir-webdriver-0.6.1/lib/watir-webdriver/browser.rb:63:in `goto'
Is there any way to avoid the program termination and working with the incompletely loaded page? I mean any timeout exception handling if possible, the most important is that my Ruby script continue without termination. I tried this, but didn't worked because I am a ruby programmer only for 3 days:
begin
browser.goto "http://example.com"
rescue Watir::Exception::NavigationException => e #catch the Exception
puts "Page did not load: #{e}"
# program continues from here
end
Try rescuing Timeout::Error instead of Watir::Exception::NavigationException.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With