【问题标题】:Selenium Webdriver error code 502Selenium Webdriver 错误代码 502
【发布时间】:2012-08-06 14:45:20
【问题描述】:

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

Selenium::WebDriver::Error::WebDriverError: 意外响应,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 时它工作正常 - 它打开浏览器没有错误 -

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

【问题讨论】:

  • 这是一件有趣的事情——当我将我的 SDK 从 JRuby 1.5.6 更改为 Ruby 1.87 时,它工作正常......问题仅在于 JRuby...... Ruby SDK 工作正常...我尝试了各种版本的 JRuby .. 比如 1.6.5 和 1.6.7,它抛出了同样的错误,但是当我尝试 1.8.7 时它工作正常 - 它打开浏览器没有错误
  • 当我的环境设置了 http_proxy/https_proxy 的 FWIW 时,我得到了这个

标签: cucumber watir-webdriver irb selenium-webdriver


【解决方案1】:

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

【讨论】:

  • 所以,我的工作是弄清楚一些事情 - 首先是我是否更改了我的代理密码.. 或者是否有任何代理设置已更改。但是,有趣的是 - 当我将我的 SDK 从 JRuby 1.56 更改为 Ruby 1.87 时,它运行良好......问题仅在于 JRuby...... Ruby SDK 也一样......
猜你喜欢
  • 2017-05-11
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-08-10
  • 1970-01-01
  • 2015-08-26
  • 2017-04-11
相关资源
最近更新 更多