我正在使用Cucumber和Capybara在Jenkins服务器上运行自动化测试。一切都适用于Firefox。但是,我遇到了设置Google Chrome和ChromeDriver的问题。我已经安装了Google Chrome和ChromeDriver(将chromedriver移动到usr / bin / chromedriver)但是当测试运行时,它会通知错误:
"Unable to find the chromedriver executable. Please download the server from http://chromedriver.storage.googleapis.com/index.html and place it somewhere on your PATH. More info at https://github.com/SeleniumHQ/selenium/wiki/ChromeDriver."
以下是我在Chrome驱动程序env.rb中的设置:
Capybara.register_driver :chrome do |app|
Capybara::Selenium::Driver.new(app, :browser => :chrome, :switches =>
%w[--ignore-certificate-errors --disable-popup-blocking])
end
如何在register_driver时设置ChromeDriver的路径?以前有没有人遇到过这个问题? 非常感谢。
答案 0 :(得分:8)
对于selenium 3.x,不推荐使用Selenium::WebDriver::Chrome.driver_path = <path to chromedriver>
。现在你必须将chrome_driver路径放在driver的声明中:
Capybara::Selenium::Driver.new(app, :browser => :chrome, :driver_path => <path to chromedriver>)
答案 1 :(得分:4)
您需要将驱动程序放在PATH中,或者您应该能够调用
Selenium::WebDriver::Chrome.driver_path = <path to chromedriver>
在初始化驱动程序之前
答案 2 :(得分:0)
您必须下载ChromeDriver。解压缩文件并将其放在PATH中的任何文件夹中。简而言之,将文件移动到Ruby文件夹,可能是C:\ Ruby22-x64 \ bin
答案 3 :(得分:0)
请将chromedriver.exe放在与ruby.exe相同的文件夹/位置。这对我有用