Watir问题--Selenium::WebDriver::Error::WebDriverError: unexpected response, code=502, content-type="te...

本机安装好Ruby + Watir环境后,在CMD中敲入irb执行下面的程序

require 'rubygems'
require 'watir'
require 'watir-webdriver'
ie=page = Watir::Browser.new :ie
ie.goto "www.google.com"

在执行 ie=page = Watir::Browser.new :ie 的报下面错误

C:\Users\zxy>irb
DL is deprecated, please use Fiddle
irb(main):001:0> require 'rubygems'
=> false
irb(main):002:0> require 'watir'
=> true
irb(main):003:0> require 'watir-webdriver'
=> true
irb(main):004:0> ie=page = Watir::Browser.new :ie
Started InternetExplorerDriver server (64-bit)
2.37.0.0
Listening on port 5555
Selenium::WebDriver::Error::WebDriverError: unexpected response, code=502, content-type="text/html"
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE>????????????</TITLE>
<META http-equiv=Content-Type content="text/html; charset=UTF-8">
<STYLE id=L_default_1>A {
        FONT-WEIGHT: bold; FONT-SIZE: 9pt; COLOR: #005a80; FONT-FAMILY: ??????
}
A:hover {
        FONT-WEIGHT: bold; FONT-SIZE: 9pt; COLOR: #0d3372; FONT-FAMILY: ??????
}
TD {
        FONT-SIZE: 9pt; FONT-FAMILY: ??????
}
TD.titleBorder {
        BORDER-RIGHT: #955319 1px solid; BORDER-TOP: #955319 1px solid; PADDING-LEFT: 8px; FONT-WEIG
HT: bold; FONT-SIZE: 12pt; VERTICAL-ALIGN: middle; BORDER-LEFT: #955319 0px solid; COLOR: #955319; B
ORDER-BOTTOM: #955319 1px solid; FONT-FAMILY: ??????; HEIGHT: 35px; BACKGROUND-COLOR: #d2b87a; TEXT-
ALIGN: left
}
TD.titleBorder_x {
        BORDER-RIGHT: #955319 0px solid; BORDER-TOP: #955319 1px solid; PADDING-LEFT: 8px; FONT-WEIG
HT: bold; FONT-SIZE: 12pt; VERTICAL-ALIGN: middle; BORDER-LEFT: #955319 1px solid; COLOR: #978c79; B
ORDER-BOTTOM: #955319 1px solid; FONT-FAMILY: tahoma; HEIGHT: 35px; BACKGROUND-COLOR: #d2b87a; TEXT-
ALIGN: left
}
.TitleDescription {
        FONT-WEIGHT: bold; FONT-SIZE: 12pt; COLOR: black; FONT-FAMILY: ??????
}
SPAN.explain {
        FONT-WEIGHT: normal; FONT-SIZE: 9pt; COLOR: #934225
}
SPAN.TryThings {
        FONT-WEIGHT: normal; FONT-SIZE: 9pt; COLOR: #934225
}
.TryList {
        MARGIN-TOP: 5px; FONT-WEIGHT: normal; FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: ??????
}
.X {
        BORDER-RIGHT: #955319 1px solid; BORDER-TOP: #955319 1px solid; FONT-WEIGHT: normal; FONT-SI
ZE: 12pt; BORDER-LEFT: #955319 1px solid; COLOR: #7b3807; BORDER-BOTTOM: #955319 1px solid; FONT-FAM
ILY: ??????; BACKGROUND-COLOR: #d1c2b4
}
.adminList {
        MARGIN-TOP: 2px
}
</STYLE>
<META content="MSHTML 6.00.2800.1170" name=GENERATOR></HEAD>
<BODY bgColor=#f3f3ed>
<TABLE cellSpacing=0 cellPadding=0 width="100%">
  <TBODY>
  <TR>
    <TD class=titleborder_x width=30>
      <TABLE height=25 cellSpacing=2 cellPadding=0 width=25 bgColor=black>
        <TBODY>
        <TR>
          <TD class=x vAlign=center align=middle>X</TD>
        </TR>
        </TBODY>
      </TABLE>
    </TD>
    <TD class=titleBorder id=L_default_2>??????????????????:<SPAN class=TitleDescription> ??????????
????????</SPAN> </TD>
  </TR>
  </TBODY>
</TABLE>

<TABLE id=spacer>
  <TBODY>
  <TR>
    <TD height=10></TD></TR></TBODY></TABLE>
<TABLE width=400>
  <TBODY>
  <TR>
    <TD noWrap width=25></TD>
    <TD width=400><SPAN class=explain><ID id=L_default_3><B>??????:</B></ID></SPAN><ID id=L_default_
4> ???????????????????????????????????????????????????????????? </ID><BR><BR>
    <B><SPAN class=tryThings><ID id=L_default_5><B>????????????:</B></ID></SPAN></B>
      <UL class=TryList>
        <LI id=L_default_6><B>?????????:</B> ???????????????????????????????????????????????????????
?????????????? Internet ??????????????????
<LI id=L_default_7><B>????????????:</B> ????????????????????????????????????????????????????????????
?????????????????????
<LI id=L_default_8><B>???????????????:</B> ?????????????????????????????????????????????????????????
??????????????????????????????

      </UL>
<ID id=L_default_9>?????????????????????????????????????????????????????????????????????????????????
??????</ID> <BR><BR>
    </TD>
  </TR>
  </TBODY>
</TABLE>

<TABLE id=spacer><TBODY><TR><TD height=15></TD></TR></TBODY></TABLE>

<TABLE width=400>
  <TBODY>
  <TR>
    <TD noWrap width=25></TD>
    <TD width=400 id=L_default_10><B>????????????(?????????????????????)</B>
      <UL class=adminList>
        <LI id=L_default_11>????????????: 502 Proxy Error???The ISA Server denied the specified Unif
orm Resource Locator (URL). (12202)
<LI id=L_default_12>IP ??????: 10.45.11.233
<LI id=L_default_13>??????: 2013-12-16 7:36:25 [GMT]
<LI id=L_default_14>?????????: ISA01
<LI id=L_default_15>???: ??????

      </UL>
    </TD>
  </TR>
  </TBODY>
</TABLE>

</BODY>
</HTML>
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/selenium-webdriver-2.38.0/lib/selenium/webdrive
r/remote/http/common.rb:66:in `create_response'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/selenium-webdriver-2.38.0/lib/selenium/webdrive
r/remote/http/default.rb:66:in `request'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/selenium-webdriver-2.38.0/lib/selenium/webdrive
r/remote/http/common.rb:40:in `call'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/selenium-webdriver-2.38.0/lib/selenium/webdrive
r/remote/bridge.rb:634:in `raw_execute'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/selenium-webdriver-2.38.0/lib/selenium/webdrive
r/remote/bridge.rb:99:in `create_session'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/selenium-webdriver-2.38.0/lib/selenium/webdrive
r/remote/bridge.rb:68:in `initialize'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/selenium-webdriver-2.38.0/lib/selenium/webdrive
r/ie/bridge.rb:47:in `initialize'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/selenium-webdriver-2.38.0/lib/selenium/webdrive
r/common/driver.rb:35:in `new'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/selenium-webdriver-2.38.0/lib/selenium/webdrive
r/common/driver.rb:35:in `for'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/selenium-webdriver-2.38.0/lib/selenium/webdrive
r.rb:67:in `for'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/watir-webdriver-0.6.4/lib/watir-webdriver/brows
er.rb:46:in `initialize'
        from (irb):4:in `new'
        from (irb):4
        from C:/Ruby200-x64/bin/irb:12:in `<main>'
irb(main):005:0>

在网上找到的解决办法:

It was solved! My network has a proxy, when I tried to install the watir, I configured the command line with the proxy, so the command line can download and install watir. After installation, I did NOT delete the proxy that I configured, it was still in the envrionment variables. That's why it fails each time I tried to start a browser with watir-webdriver. Delete this proxy, everything works fine.

由于在安装的时候在命令行中设置的代理,而在执行程序的时候没有去掉代理,导致错误。

如果在Windows环境下的话,重新开启一个CMD窗口就行了

 

转载于:https://www.cnblogs.com/CI131204/p/3476904.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值