zoukankan      html  css  js  c++  java
  • Watir问题--Selenium::WebDriver::Error::WebDriverError: unexpected response, code=502, content-type="text/html"

    本机安装好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:Userszxy>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窗口就行了

  • 相关阅读:
    重新开始学习javase_对象的摧毁
    昨天一日和彭讨论post请求数据的问题
    昨天在公司加班,上午好像就是弄一个ftp的linux服务问题
    昨天有是发现一个新的技术问题
    昨天下午快要下班的时候让他们东软测试
    昨天也没有和家里通话,把时间给了一位同事
    早上8:45到达
    又是一个月初
    今天是下雨天
    从每天开始在工作上才算有点事情
  • 原文地址:https://www.cnblogs.com/CI131204/p/3476904.html
Copyright © 2011-2022 走看看