我正在尝试在 Ubuntu 10.04 上为 Ruby 运行 Watir。我已经在我的(无显示)服务器上安装了 Chrome 和 ChromeDriver,并安装了 selenium-webdriver Gem。但是当我尝试在 Watir 中创建浏览器时,我得到:
$ 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>
在“Watir::Browser.new”调用后长时间停顿,我假设某种超时?也许试图与 Chromedriver 交谈?我正在运行相关 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)