1


环境 - 64 位 Windows 7
ruby​​ 1.9.2- P290 ruby
​​gems 1.8.24
Watir 4.0.2

尝试创建浏览器(Chrome 或 IE)实例时,将失败并出现以下错误
尝试创建 Firefox 实例时,它将打开 Firefox,然后自动关闭并出现相同的错误。

irb(main):001:0> require 'rubygems'  
=> true  
irb(main):002:0> require 'watir-webdriver'  
=> true  
irb(main):003:0> ie = Watir::Browser.new:chrome  
Started ChromeDriver  
port=9515  
version=23.0.1240.0  
log=C:\Users\y93529\chromedriver.log  
Selenium::WebDriver::Error::WebDriverError: unexpected response, code=502, conte
nt-type="text/html"
<HEAD><TITLE>Connection refused</TITLE></HEAD>
<BODY BGCOLOR="white" FGCOLOR="black"><H1>Connection refused</H1><HR>
<FONT FACE="Helvetica,Arial"><B>
Description: Connection refused</B></FONT>
<HR>
<!-- default "Connection refused" response (502) -->
</BODY>
    from C:/ruby/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.27.2/lib/sele
nium/webdriver/remote/http/common.rb:66:in `create_response'
    from C:/ruby/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.27.2/lib/sele
nium/webdriver/remote/http/default.rb:66:in `request'
    from C:/ruby/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.27.2/lib/sele
nium/webdriver/remote/http/common.rb:40:in `call'
    from C:/ruby/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.27.2/lib/sele
nium/webdriver/remote/bridge.rb:615:in `raw_execute'
    from C:/ruby/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.27.2/lib/sele
 nium/webdriver/remote/bridge.rb:92:in `create_session'
    from C:/ruby/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.27.2/lib/sele
 nium/webdriver/remote/bridge.rb:68:in `initialize'
    from C:/ruby/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.27.2/lib/sele
nium/webdriver/chrome/bridge.rb:29:in `initialize'
    from C:/ruby/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.27.2/lib/sele
nium/webdriver/common/driver.rb:37:in `new'
    from C:/ruby/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.27.2/lib/sele
nium/webdriver/common/driver.rb:37:in `for'
    from C:/ruby/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.27.2/lib/sele
nium/webdriver.rb:67:in `for'
    from C:/ruby/lib/ruby/gems/1.9.1/gems/watir-webdriver-0.6.2/lib/watir-we
bdriver/browser.rb:46:in `initialize'
    from (irb):3:in `new'
    from (irb):3
    from C:/ruby/bin/irb:12:in `<main>'

补充一点 - 32 位 windows 7 中的相同环境,一切正常。我怀疑64位win7和32位win7对webdriver的支持是否有区别

任何建议将不胜感激。

4

1 回答 1

2

解决了!我的网络有代理,当我尝试安装watir时,我用代理配置了命令行,所以命令行可以下载安装watir。安装后,我没有删除我配置的代理,它仍然在环境变量中。这就是为什么每次我尝试使用 watir-webdriver 启动浏览器时它都会失败。删除此代理,一切正常。

感谢你们参与解决这个问题。

于 2013-01-05T03:35:42.060 回答