我正在使用FF7.x,当watir-webdriver有时会导致浏览器挂起并抛出以下错误:
Errno::ECONNREFUSED: No connection could be made because the target machine actively refused it. - connect(2)
C:/Ruby187/lib/ruby/1.8/net/http.rb:560:in `initialize'
C:/Ruby187/lib/ruby/1.8/net/http.rb:560:in `open'
C:/Ruby187/lib/ruby/1.8/net/http.rb:560:in `connect'
C:/Ruby187/lib/ruby/1.8/timeout.rb:67:in `timeout'
C:/Ruby187/lib/ruby/1.8/timeout.rb:101:in `timeout'
C:/Ruby187/lib/ruby/1.8/net/http.rb:560:in `connect'
C:/Ruby187/lib/ruby/1.8/net/http.rb:553:in `do_start'
C:/Ruby187/lib/ruby/1.8/net/http.rb:542:in `start'
C:/Ruby187/lib/ruby/1.8/net/http.rb:1035:in `request'
C:/Ruby187/lib/ruby/gems/1.8/gems/selenium-webdriver-2.13.0/lib/selenium/webdriver/remote/http/default.rb:81:in `response_for'
C:/Ruby187/lib/ruby/gems/1.8/gems/selenium-webdriver-2.13.0/lib/selenium/webdriver/remote/http/default.rb:43:in `request'
C:/Ruby187/lib/ruby/gems/1.8/gems/selenium-webdriver-2.13.0/lib/selenium/webdriver/remote/http/common.rb:39:in `call'
C:/Ruby187/lib/ruby/gems/1.8/gems/selenium-webdriver-2.13.0/lib/selenium/webdriver/remote/bridge.rb:450:in `raw_execute'
C:/Ruby187/lib/ruby/gems/1.8/gems/selenium-webdriver-2.13.0/lib/selenium/webdriver/remote/bridge.rb:428:in `execute'
C:/Ruby187/lib/ruby/gems/1.8/gems/selenium-webdriver-2.13.0/lib/selenium/webdriver/remote/bridge.rb:185:in `quit'
C:/Ruby187/lib/ruby/gems/1.8/gems/selenium-webdriver-2.13.0/lib/selenium/webdriver/firefox/bridge.rb:43:in `quit'
C:/Ruby187/lib/ruby/gems/1.8/gems/selenium-webdriver-2.13.0/lib/selenium/webdriver/common/driver.rb:162:in `quit'
C:/Ruby187/lib/ruby/gems/1.8/gems/watir-webdriver-0.3.9/lib/watir-webdriver/browser.rb:85:in `close'
C:/Perf/AutoItData/scripts/MasterScript.rb:320:in `test_everything_off'
C:/Perf/AutoItData/scripts/MasterScript.rb:120:in `each'
C:/Perf/AutoItData/scripts/MasterScript.rb:120:in `test_everything_off'
此外,这个问题导致整个脚本流产。
如何解决这个问题?
答案 0 :(得分:0)
首先,请将您的所有宝石更新为最新版本。
其次,尝试更高的Http超时
client = Selenium::WebDriver::Remote::Http::Default.new
client.timeout = 180 # seconds – default is 60
b = Watir::Browser.new :firefox, :http_client => client