cucumber - Selenium Webdriver 错误代码 502

标签 cucumber watir-webdriver irb selenium-webdriver

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

Selenium::WebDriver::Error::WebDriverError:意外响应,代码=502,内容类型=“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)'>> 

从今天早上开始,这种情况突然发生,所以,我的问题是..错误代码 = 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 时它工作正常 - 它打开浏览器没有错误 –

这是使用 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">

最佳答案

502是HTTP响应码,代表Bad Gateway - 该问题是由于您的请求所经过的上游服务器之一配置错误或错误造成的。

关于cucumber - Selenium Webdriver 错误代码 502,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11830581/

相关文章:

Ruby - 如何在读取文件时跳过/忽略特定行?

watir-webdriver - chromedriver 在 Windows 7 上崩溃

ruby-on-rails - 自动加载项目的环境到 irb

regex - 如何仅单击一个类中的链接

ruby-on-rails-3 - 如何在Rails控制台中加载环境变量?

ruby - 这是 ruby 中的任何条件类型吗? !!() , !() , !0, !!0

ruby - 为什么我在 Cucumber 中得到 'Undefined dynamic step'?

selenium - Capybara,从下拉列表中选择第一个选项?

ruby-on-rails - 使用 Cucumber 测试分页功能

ruby - Watir Webdriver 脚本生成