我在使Chrome与64位Ubuntu 13.10上的RSpec / Capybara配合使用时遇到麻烦。默认情况下,它会启动Firefox- 我们尝试了多种更改方式,包括:
http://actsasblog.ca/2011/09/28/how-to-use-chrome-with- capybara/
/home/.../xxx_spec.rb:8:in‘: undefined local variable or method “chromedriver”' for main:Object (NameError)
/home/.../xxx_spec.rb:8:in
“chromedriver”' for main:Object (NameError)
我们还尝试了:
require 'capybara/rspec' require 'rspec' require 'selenium-webdriver' Capybara.register_driver :selenium do |app| Capybara::Selenium::Driver.new(app, :browser => :chrome) end
/home/ubuntu/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/selenium- webdriver-2.39.0/lib/selenium/webdriver/chrome/service.rb:50:instart’: unable to connect to chromedriver http://127.0.0.1:9515 (Selenium::WebDriver::Error::WebDriverError)`
/home/ubuntu/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/selenium- webdriver-2.39.0/lib/selenium/webdriver/chrome/service.rb:50:in
要使用Chrome,还需要执行其他步骤吗?我是Selenium的新手。
如果我没记错的话:
我chromedriver从此资源https://code.google.com/p/selenium/wiki/ChromeDriver下载了最新的
chromedriver
然后插入 spec_helper.rb
spec_helper.rb
Capybara.register_driver :chrome do |app| Capybara::Selenium::Driver.new(app, :browser => :chrome) end Capybara.javascript_driver = :chrome
它为我工作