获取错误Timeout :: Error:Timeout ::使用Watir-webdriver的Firefox出错

时间:2014-06-18 20:19:58

标签: selenium-webdriver watir-webdriver

我想使用firefox 17运行我的脚本但是它会正确启动但无法完全导航。 它会产生Timeout::Error: Timeout::Error。 我没有看到Chrome或IE的这个错误。 使用JRuby 1.7.12,Watir-Webdriver 0.6.10 selenium-webdriver 2.42.0

require 'watir-webdriver'
b = Watir::Browser.new 'firefox'
b.goto 'bit.ly/watir-webdriver-demo'
b.text_field(:id => 'entry_0').set 'your name'

错误消息

Timeout::Error: Timeout::Error
from C:/jruby-1.7.12/lib/ruby/1.9/net/protocol.rb:146:in `rbuf_fill'
    from C:/jruby-1.7.12/lib/ruby/1.9/net/protocol.rb:122:in `readuntil'
    from C:/jruby-1.7.12/lib/ruby/1.9/net/protocol.rb:132:in `readline'
    from C:/jruby-1.7.12/lib/ruby/1.9/net/http.rb:2570:in `read_status_line'
    from C:/jruby-1.7.12/lib/ruby/1.9/net/http.rb:2559:in `read_new'
    from C:/jruby-1.7.12/lib/ruby/1.9/net/http.rb:1327:in `transport_request'
    from org/jruby/RubyKernel.java:1264:in `catch'
    from C:/jruby-1.7.12/lib/ruby/1.9/net/http.rb:1324:in `transport_request'
    from C:/jruby-1.7.12/lib/ruby/1.9/net/http.rb:1301:in `request'
    from C:/jruby-1.7.12/lib/ruby/1.9/net/http.rb:1294:in `request'
    from C:/jruby-1.7.12/lib/ruby/1.9/net/http.rb:745:in `start'
    from C:/jruby-1.7.12/lib/ruby/1.9/net/http.rb:1292:in `request'
    from C:/jruby-1.7.12/lib/ruby/gems/shared/gems/selenium-webdriver-2.42.0/lib/selenium/webdriver/remote/http/default.rb:83:in `response_for'
    from C:/jruby-1.7.12/lib/ruby/gems/shared/gems/selenium-webdriver-2.42.0/lib/selenium/webdriver/remote/http/default.rb:39:in `request'
    from C:/jruby-1.7.12/lib/ruby/gems/shared/gems/selenium-webdriver-2.42.0/lib/selenium/webdriver/remote/http/common.rb:40:in `call'
    from C:/jruby-1.7.12/lib/ruby/gems/shared/gems/selenium-webdriver-2.42.0/lib/selenium/webdriver/remote/bridge.rb:634:in `raw_execute'
    from C:/jruby-1.7.12/lib/ruby/gems/shared/gems/selenium-webdriver-2.42.0/lib/selenium/webdriver/remote/bridge.rb:612:in `execute'
    from C:/jruby-1.7.12/lib/ruby/gems/shared/gems/selenium-webdriver-2.42.0/lib/selenium/webdriver/remote/bridge.rb:110:in `get'
    from C:/jruby-1.7.12/lib/ruby/gems/shared/gems/selenium-webdriver-2.42.0/lib/selenium/webdriver/common/navigation.rb:14:in `to'
    from C:/jruby-1.7.12/lib/ruby/gems/shared/gems/watir-webdriver-0.6.10/lib/watir-webdriver/browser.rb:77:in `goto'
    from (irb):3:in `evaluate'
    from org/jruby/RubyKernel.java:1101:in `eval'
    from org/jruby/RubyKernel.java:1501:in `loop'
    from org/jruby/RubyKernel.java:1264:in `catch'
    from org/jruby/RubyKernel.java:1264:in `catch'
    from C:\jruby-1.7.12\/bin/jirb_swing:53:in `(root)

2 个答案:

答案 0 :(得分:0)

在我的案例中,这有助于:

 TIMEOUT = 300 # set some value in seconds, f.ex. 300
 client = Selenium::WebDriver::Remote::Http::Default.new
 client.timeout = TIMEOUT # seconds – default is 60
 browser = Watir::Browser.new :firefox, :http_client => client

我也找到了:

require 'net/http' 
http = Net::HTTP.new(@host, @port)
http.read_timeout = 500

请检查它是否对您的情况有帮助。

答案 1 :(得分:0)

更新您的宝石,特别是gem update selenium-webdriver