使用JRuby Watir时出现HTTP Path Empty错误

时间:2012-06-18 20:18:53

标签: ruby rubygems jruby watir watir-webdriver

我在Windows 7机器上安装了JRuby 1.6.7.2(64位)和JDK 1.7.x(64位)。现在我只是尝试使用Watir启动浏览器(Firefox 13.0),但我一直在收到一个HTTP错误,似乎是来自JRuby + gems的内部。我使用以下命令安装了gem:

jgem install watir-webdriver
jgem install rspec
jgem install capybara
jgem install page-object
jgem install bundler
jgem install jruby-jars

以下是我尝试使用Watir打开浏览器时遇到的stacktrace错误:

C:\Windows\System32>jirb
irb(main):001:0> require 'rubygems'
=> true
irb(main):002:0> require 'watir-webdriver'
=> true
irb(main):003:0> b = Watir::Browser.start("http://www.google.com", :firefox)
[WARNING] MultiJson is using the default adapter (ok_json). We recommend loading
a different JSON library to improve performance.
ArgumentError: HTTP request path is empty
    from C:/Ruby/jruby-1.6.7.2/lib/ruby/1.8/net/http.rb:1476:in `initialize'

    from C:/Ruby/jruby-1.6.7.2/lib/ruby/1.8/net/http.rb:1594:in `initialize'

    from C:/Ruby/jruby-1.6.7.2/lib/ruby/gems/1.8/gems/selenium-webdriver-2.2
    2.2/lib/selenium/webdriver/remote/http/default.rb:64:in `new_request_for'

    from C:/Ruby/jruby-1.6.7.2/lib/ruby/gems/1.8/gems/selenium-webdriver-2.2 
    2.2/lib/selenium/webdriver/remote/http/default.rb:34:in `request'

    from C:/Ruby/jruby-1.6.7.2/lib/ruby/gems/1.8/gems/selenium-webdriver-2.2
    2.2/lib/selenium/webdriver/remote/http/default.rb:57:in `request'

    from C:/Ruby/jruby-1.6.7.2/lib/ruby/gems/1.8/gems/selenium-webdriver-2.2
    2.2/lib/selenium/webdriver/remote/http/common.rb:40:in `call'

    from C:/Ruby/jruby-1.6.7.2/lib/ruby/gems/1.8/gems/selenium-webdriver-2.2
    2.2/lib/selenium/webdriver/remote/bridge.rb:598:in `raw_execute'

    from C:/Ruby/jruby-1.6.7.2/lib/ruby/gems/1.8/gems/selenium-webdriver-2.2
    2.2/lib/selenium/webdriver/remote/bridge.rb:92:in `create_session'

    from C:/Ruby/jruby-1.6.7.2/lib/ruby/gems/1.8/gems/selenium-webdriver-2.2
    2.2/lib/selenium/webdriver/remote/bridge.rb:68:in `initialize'

    from C:/Ruby/jruby-1.6.7.2/lib/ruby/gems/1.8/gems/selenium-webdriver-2.2
    2.2/lib/selenium/webdriver/firefox/bridge.rb:28:in `initialize'

    from C:/Ruby/jruby-1.6.7.2/lib/ruby/gems/1.8/gems/selenium-webdriver-2.2
    2.2/lib/selenium/webdriver/common/driver.rb:31:in `for'

    from C:/Ruby/jruby-1.6.7.2/lib/ruby/gems/1.8/gems/selenium-webdriver-2.2
    2.2/lib/selenium/webdriver.rb:65:in `for'

    from C:/Ruby/jruby-1.6.7.2/lib/ruby/gems/1.8/gems/watir-webdriver-0.6.1/
    lib/watir-webdriver/browser.rb:35:in `initialize'

    from C:/Ruby/jruby-1.6.7.2/lib/ruby/gems/1.8/gems/watir-webdriver-0.6.1/
    lib/watir-webdriver/browser.rb:18:in `start'

    from (irb):3:in `evaluate'
    from org/jruby/RubyKernel.java:1083:in `eval'
    from C:/Ruby/jruby-1.6.7.2/lib/ruby/1.8/irb.rb:158:in `eval_input'
    from C:/Ruby/jruby-1.6.7.2/lib/ruby/1.8/irb.rb:271:in `signal_status'
    from C:/Ruby/jruby-1.6.7.2/lib/ruby/1.8/irb.rb:155:in `eval_input'
    from org/jruby/RubyKernel.java:1410:in `loop'
    from org/jruby/RubyKernel.java:1183:in `catch'
    from C:/Ruby/jruby-1.6.7.2/lib/ruby/1.8/irb.rb:154:in `eval_input'
    from C:/Ruby/jruby-1.6.7.2/lib/ruby/1.8/irb.rb:71:in `start'
    from org/jruby/RubyKernel.java:1183:in `catch'
    from C:/Ruby/jruby-1.6.7.2/lib/ruby/1.8/irb.rb:70:in `start'
    from C:\Ruby\jruby-1.6.7.2\bin\jirb:13:in `(root)'irb(main):004:0>

我有selenium webdrivers即& chrome添加到我的classpath中。当我用ie或chrome执行此命令时,我得到类似的HTTP错误。这是我必须手动对gem文件做的修复吗?

1 个答案:

答案 0 :(得分:3)

我和watir-webdriver gem有同样的错误。 问题是http代理设置,解决方案是在代码之前添加no_proxy env。

ENV['no_proxy'] = "127.0.0.1"

我希望能帮到你!