JRuby: Watir hangs on browser startup

I have Windows 7 Enterprise and am trying to run JRuby. I 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 that seems to work because I can successfully load gems for Ruby and JRuby and they are saved on my local drive.

When I try to launch a browser (e.g. firefox, chrome), it seems to freeze for JRuby but not Ruby. Here is the trace for JRuby after she tried 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 seems to be hanging because it is looking for an open port. We need to use an HTTP proxy for our network, and I also have a system variable. I really don't know why Vatyr will work on Ruby, but not on JRuby.

+4
source share
1 answer

I had a similar problem - selenium-webdriver did not open the browser when using JRuby and Java 6, however it worked with Java 7.

I found out that Java 6 seems to have some problems with IPv6, and it could not find a free port on IPv6 interfaces.

The solution is to add -Djava.net.preferIPv4Stack=true to JAVA_OPTS so that Java will prefer IPv4 over IPv6 whenever possible.

+6
source

All Articles