2

从今天开始不知何故,我的 Cucumber 代码出现以下错误 -

Selenium::WebDriver::Error::WebDriverError: unexpected response, code=502, content-type="text/html" 然后是页面的整个 HTML 文本。

这是完整的 IRB 控制台交互 -

C:\jruby-1.6.5\bin\jruby.exe --1.8 -e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift) C:/jruby-1.6.5/bin/jirb - prompt simple
>> require "rubygems"
=> true

?> require "watir-webdriver"
=> true

?> @browser = Watir::Browser.new :ie
Started InternetExplorerDriver server (32-bit) 
2.25.2.0
Listening on port 5555
Selenium::WebDriver::Error::WebDriverError: unexpected response, code=502, content-type="text/html"
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>

<!-- Page creation information:
   FileName: cannotconnect.html
   Language: [my] New Language Pack
Created with: Language Pack Designer 0.0.0.8
Creation date: 9/26/2011 10:19:48 AM
-->

<!--Head-->
<head>
  <title>Can

...然后是我不在这里粘贴的大型 HTML 转储

& 在最后 -

</html>
from C:/jruby-1.6.5/lib/ruby/gems/1.8/gems/selenium-webdriver-2.24.0/lib/selenium/webdriver/remote/http/common.rb:66:in `create_response'
from C:/jruby-1.6.5/lib/ruby/gems/1.8/gems/selenium-webdriver-2.24.0/lib/selenium/webdriver/remote/http/default.rb:59:in `request'
from C:/jruby-1.6.5/lib/ruby/gems/1.8/gems/selenium-webdriver-2.24.0/lib/selenium/webdriver/remote/http/common.rb:40:in `call'
from C:/jruby-1.6.5/lib/ruby/gems/1.8/gems/selenium-webdriver-2.24.0/lib/selenium/webdriver/remote/bridge.rb:598:in `raw_execute'
from C:/jruby-1.6.5/lib/ruby/gems/1.8/gems/selenium-webdriver-2.24.0/lib/selenium/webdriver/remote/bridge.rb:92:in `create_session'
from C:/jruby-1.6.5/lib/ruby/gems/1.8/gems/selenium-webdriver-2.24.0/lib/selenium/webdriver/remote/bridge.rb:68:in `initialize'
from C:/jruby-1.6.5/lib/ruby/gems/1.8/gems/selenium-webdriver-2.24.0/lib/selenium/webdriver/ie/bridge.rb:43:in `initialize'
from C:/jruby-1.6.5/lib/ruby/gems/1.8/gems/selenium-webdriver-2.24.0/lib/selenium/webdriver/common/driver.rb:35:in `for'
from C:/jruby-1.6.5/lib/ruby/gems/1.8/gems/selenium-webdriver-2.24.0/lib/selenium/webdriver.rb:65:in `for'
from C:/jruby-1.6.5/lib/ruby/gems/1.8/gems/watir-webdriver-0.5.8/lib/watir-webdriver/browser.rb:35:in `initialize'
from (irb):7:in `evaluate'
from org/jruby/RubyKernel.java:1088:in `eval'
from C:/jruby-1.6.5/lib/ruby/1.8/irb.rb:158:in `eval_input'
from C:/jruby-1.6.5/lib/ruby/1.8/irb.rb:271:in `signal_status'
from C:/jruby-1.6.5/lib/ruby/1.8/irb.rb:155:in `eval_input'
from org/jruby/RubyKernel.java:1420:in `loop'
from org/jruby/RubyKernel.java:1192:in `catch'
from C:/jruby-1.6.5/lib/ruby/1.8/irb.rb:154:in `eval_input'
from C:/jruby-1.6.5/lib/ruby/1.8/irb.rb:71:in `start'
from org/jruby/RubyKernel.java:1192:in `catch'
from C:/jruby-1.6.5/lib/ruby/1.8/irb.rb:70:in `start'
from C:/jruby-1.6.5/bin/jirb:13:in `(root)'
from org/jruby/RubyKernel.java:1063:in `load'
from -e:1:in `(root)'>> 

从今天早上开始突然发生这种情况,所以,我的问题是.. error code = 502 是什么意思?如果您查看此日志的顶部 - 它说

Selenium::WebDriver::Error::WebDriverError: unexpected response, code=502

那么,这是什么意思?问题出在哪里?是代理问题还是别的什么?我尝试了不同的浏览器并遇到相同的问题?

更新 -

这是有趣的事情 - 当我将我的 SDK 从 JRuby 1.5.6 更改为 Ruby 1.87 时,它工作正常......问题只出在 JRuby 上...... Ruby SDK 工作正常......我尝试了各种版本JRuby .. 像 1.6.5 和 1.6.7 一样,它抛出了同样的错误,但是当我尝试 1.8.7 时它工作正常 - 它打开浏览器没有错误 -</p>

这是 Ruby 1.8.7 的代码

C:\Ruby187\bin\ruby.exe -e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift)     C:/Ruby187/bin/irb --prompt simple
>> require "rubygems"
=> true

?> require "watir-webdriver"
=> true

?> @browser = Watir::Browser.new :ie
=> #<Watir::Browser:0x2e18b00 url="http://localhost:5555/" title="WebDriver">

?> @browser = Watir::Browser.new :ie
=> #<Watir::Browser:0x2ef07a0 url="http://localhost:5555/" title="WebDriver">
4

1 回答 1

3

502 是 HTTP 响应代码,表示网关错误- 问题是由于您的请求正在通过的上游服务器之一上的配置错误或错误。

于 2012-08-06T14:51:22.987 回答