1
votes

I'm trying to run Watir for Ruby on Ubuntu 10.04. I've installed Chrome and ChromeDriver on my (displayless) server, and installed the selenium-webdriver Gem. But when I try to create a browser in Watir, I get:

$ irb
irb(main):001:0> require 'rubygems'
=> true
irb(main):002:0> require 'watir-webdriver'
=> true
irb(main):003:0> browser = Watir::Browser.new :chrome
NoMethodError: undefined method `closed?' for nil:NilClass
        from /usr/lib/ruby/1.8/net/http.rb:1060:in `request'
        from /usr/lib/ruby/gems/1.8/gems/selenium-webdriver-2.26.0/lib/selenium/webdriver/remote/http/default.rb:83:in `response_for'
        from /usr/lib/ruby/gems/1.8/gems/selenium-webdriver-2.26.0/lib/selenium/webdriver/remote/http/default.rb:39:in `request'
        from /usr/lib/ruby/gems/1.8/gems/selenium-webdriver-2.26.0/lib/selenium/webdriver/remote/http/common.rb:40:in `call'
        from /usr/lib/ruby/gems/1.8/gems/selenium-webdriver-2.26.0/lib/selenium/webdriver/remote/bridge.rb:598:in `raw_execute'
        from /usr/lib/ruby/gems/1.8/gems/selenium-webdriver-2.26.0/lib/selenium/webdriver/remote/bridge.rb:92:in `create_session'
        from /usr/lib/ruby/gems/1.8/gems/selenium-webdriver-2.26.0/lib/selenium/webdriver/remote/bridge.rb:68:in `initialize'
        from /usr/lib/ruby/gems/1.8/gems/selenium-webdriver-2.26.0/lib/selenium/webdriver/chrome/bridge.rb:29:in `initialize'
        from /usr/lib/ruby/gems/1.8/gems/selenium-webdriver-2.26.0/lib/selenium/webdriver/common/driver.rb:37:in `new'
        from /usr/lib/ruby/gems/1.8/gems/selenium-webdriver-2.26.0/lib/selenium/webdriver/common/driver.rb:37:in `for'
        from /usr/lib/ruby/gems/1.8/gems/selenium-webdriver-2.26.0/lib/selenium/webdriver.rb:65:in `for'
        from /usr/lib/ruby/gems/1.8/gems/watir-webdriver-0.5.5/lib/watir-webdriver/browser.rb:35:in `initialize'
        from (irb):3:in `new'
        from (irb):3
        from :0
irb(main):004:0>

Long pause after the "Watir::Browser.new" call, I'm assuming some sort of timeout? Maybe trying to talk with Chromedriver? I'm running these versions of the relevant Gems:

$ gem list

*** LOCAL GEMS ***

addressable (2.3.2)
childprocess (0.3.6)
fastercsv (1.5.5)
ffi (1.2.0, 1.0.11)
libwebsocket (0.1.3)
multi_json (1.3.7, 1.0.4)
rubygems-update (1.8.24)
rubyzip (0.9.9)
selenium-webdriver (2.26.0, 2.18.0)
watir-webdriver (0.5.5)
websocket (1.0.3)
yajl-ruby (1.1.0)
1

1 Answers

1
votes

I'm trying to run Chrome headless, and I didn't have an X server running. Xvfb did the trick, and I'm working now:

http://en.wikipedia.org/wiki/Xvfb

http://blog.kagesenshi.org/2007/06/running-x-applications-headless-using.html