JRuby:Watir在启动浏览器时挂起 [英] JRuby: Watir is hanging when launching browser

查看:180
本文介绍了JRuby:Watir在启动浏览器时挂起的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有Windows 7企业版,我正在尝试运行JRuby。我为Ruby(1.9.3),Java(jdk - 1.6.7)和JRuby(1.7preview)设置了我的环境变量。我有一个网络驱动器,但我创建了一个HOME系统变量,它似乎正在工作,因为我可以下载Ruby和EX的宝石; JRuby成功并将它们保存到我的本地驱动器中。

I have Windows 7 Enterprise and I am trying to run JRuby. I've set my environment variables for Ruby (1.9.3), Java (jdk - 1.6.7), and JRuby (1.7preview). I have a network drive but I created a HOME system variable which seems to be working because I can download gems for both Ruby & JRuby successfully and they are saved to my local drive.

当我尝试启动浏览器(即firefox,chrome)时,它似乎挂起了JRuby,但不是Ruby。以下是 JRuby 在尝试执行10分钟后的跟踪:

When I try to launch a browser (ie, firefox, chrome) it seems to hang for JRuby, but not Ruby. Here is the trace for JRuby after it's been trying to execute for 10 minutes:

irb(main):003:0> require 'rubygems'
=> false
irb(main):004:0> require 'watir-webdriver'
=> true
irb(main):005:0> b = Watir::Browser.new :ie
IRB::Abort: abort then interrupt! *<--Note I killed the process after 10 minutes*
    from c:/Ruby/jruby-bin-1.7.0.preview1/jruby-1.7.0.preview1/lib/ruby/gems
    /shared/gems/selenium-webdriver-2.22.2/lib/selenium/webdriver/common 
    /port_prober.rb:24:in `free?'       
    from c:/Ruby/jruby-bin-1.7.0.preview1/jruby-1.7.0.preview1/lib/ruby/gems
    /shared/gems/selenium-webdriver-2.22.2/lib/selenium/webdriver/common  
    /port_prober.rb:5:in `above'        
    from c:/Ruby/jruby-bin-1.7.0.preview1/jruby-1.7.0.preview1/lib/ruby/gems
    /shared/gems/selenium-webdriver-2.22.2/lib/selenium/webdriver/ie/bridge.rb:17:in
   `initialize'
    from org/jruby/RubyHash.java:1429:in `delete'
    from c:/Ruby/jruby-bin-1.7.0.preview1/jruby-1.7.0.preview1/lib/ruby/gems
    /shared/gems/selenium-webdriver-2.22.2/lib/selenium/webdriver/ie/bridge.rb:17:in
    `initialize'
    from c:/Ruby/jruby-bin-1.7.0.preview1/jruby-1.7.0.preview1/lib/ruby/gems
    /shared/gems/selenium-webdriver-2.22.2/lib/selenium/webdriver/common/driver.rb:3
    5:in `for'
    from c:/Ruby/jruby-bin-1.7.0.preview1/jruby-1.7.0.preview1/lib/ruby/gems
    /shared/gems/selenium-webdriver-2.22.2/lib/selenium/webdriver.rb:65:in `for'
    from c:/Ruby/jruby-bin-1.7.0.preview1/jruby-1.7.0.preview1/lib/ruby/gems
    /shared/gems/watir-webdriver-0.6.1/lib/watir-webdriver/browser.rb:35:in   
    `initialize'
    from (irb):5:in `evaluate'
    from org/jruby/RubyKernel.java:1037:in `eval'
    from org/jruby/RubyKernel.java:1353:in `loop'
    from org/jruby/RubyKernel.java:1146:in `catch'
    from org/jruby/RubyKernel.java:1146:in `catch'
    from c:\Ruby\jruby-bin-1.7.0.preview1\jruby-1.7.0.preview1\bin\irb:13:in
    `(root)'

JRuby似乎挂了,因为它正在寻找对于一个开放的港口。我们必须为我们的网络使用HTTP代理,我也为此设置了一个系统变量。我真的不知道为什么Watir会为Ruby而不是JRuby工作。

JRuby seems to hang because it's looking for an open port. We have to use an HTTP proxy for our network and I have setup a system variable for that as well. I really have no idea why Watir would work for Ruby but not JRuby.

推荐答案

我有类似的问题 - selenium-webdriver 没有打开浏览器当使用JRuby和Java 6时,它使用Java 7。

I had similar problem - selenium-webdriver was not opening browser when using JRuby and Java 6, however it worked with Java 7.

我发现Java 6似乎有一些IPv6问题,它找不到免费的IPv6接口上的端口。

I found out that Java 6 seems to have some problems with IPv6, and it couldn't find free port on IPv6 interfaces.

解决方案是将 -Djava.net.preferIPv4Stack = true 添加到 JAVA_OPTS 告诉Java在可能的情况下更喜欢IPv4 over IPv6。

Solution is to add -Djava.net.preferIPv4Stack=true to JAVA_OPTS telling Java to prefer IPv4 over IPv6 when possible.

这篇关于JRuby:Watir在启动浏览器时挂起的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆