小编典典

将Chrome设置为RSpec / Capybara的默认浏览器

selenium

我在使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)

我们还尝试了:

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)`

要使用Chrome,还需要执行其他步骤吗?我是Selenium的新手。


阅读 331

收藏
2020-06-26

共1个答案

小编典典

如果我没记错的话:

chromedriver从此资源https://code.google.com/p/selenium/wiki/ChromeDriver下载了最新的

然后插入 spec_helper.rb

Capybara.register_driver :chrome do |app|
  Capybara::Selenium::Driver.new(app, :browser => :chrome)
end

Capybara.javascript_driver = :chrome

它为我工作

2020-06-26