Joe Joe -5 years ago 496
Ruby Question

Watir browser process doesn't start properly (Windows)

I've built a simple script in Linux, but now I'm trying to get it to work on windows.

The code is:

require 'watir-webdriver'
puts "Press enter when ready to continue"
browser = Watir::Browser.start ""
# do stuff

It works exactly as expected on Ubuntu. But when I try it on Windows, the Firefox process starts, but then dies before you even see a Firefox window. This is a fresh install of Ruby on this Windows installation, I've never used it before on this machine.

What could be the problem?

Edit: Command line trace, as requested.

C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/selenium-webdriver-2.53.1/lib/selenium/webdriver/firefox/launcher.rb:90:in `connect_until_stable': unable to obtain stable firefox connection in 60 seconds ( (Selenium::WebDriver::Error::WebDriverError)
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/selenium-webdriver-2.53.1/lib/selenium/webdriver/firefox/launcher.rb:55:in `block in launch'
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/selenium-webdriver-2.53.1/lib/selenium/webdriver/common/socket_lock.rb:43:in `locked'
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/selenium-webdriver-2.53.1/lib/selenium/webdriver/firefox/launcher.rb:51:in `launch'
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/selenium-webdriver-2.53.1/lib/selenium/webdriver/firefox/bridge.rb:43:in `initialize'
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/selenium-webdriver-2.53.1/lib/selenium/webdriver/common/driver.rb:53:in `new'
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/selenium-webdriver-2.53.1/lib/selenium/webdriver/common/driver.rb:53:in `for'
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/selenium-webdriver-2.53.1/lib/selenium/webdriver.rb:84:in `for'
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/watir-webdriver-0.9.1/lib/watir-webdriver/browser.rb:46:in `initialize'
from bot.rb:8:in `new'
from bot.rb:8:in `<main>'

Answer Source

That's this bug in Firefox. Your options are:

  1. Wait for the patch in Firefox 47
  2. Downgrade to Firefox 46
  3. Use Marionette instead of the Firefox Driver (which is being deprecated and won't work with new versions of Firefox soon)
  4. Use Chrome

To try marionette, download the geckodriver and do:

browser = :firefox, marionette: true
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download