Watir browser process doesn't start properly (Windows)

别来无恙 提交于 2019-12-31 06:20:22

问题


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"
gets
browser = Watir::Browser.start "http://www.google.com"
# 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 (127.0.0.1:7055) (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>'

回答1:


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 = Watir::Browser.new :firefox, marionette: true


来源:https://stackoverflow.com/questions/37791604/watir-browser-process-doesnt-start-properly-windows

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!