如何在Ruby中的Jenkins服务器上设置运行ChromeDriver for Cucumber的路径?

Huy*_* Do 5 capybara selenium-chromedriver selenium-webdriver

我正在使用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." 
Run Code Online (Sandbox Code Playgroud)

以下是我在env.rb中针对Chrome驱动程序的设置:

  Capybara.register_driver :chrome do |app|
    Capybara::Selenium::Driver.new(app, :browser => :chrome, :switches =>
      %w[--ignore-certificate-errors --disable-popup-blocking])
  end
Run Code Online (Sandbox Code Playgroud)

如何在register_driver时设置ChromeDriver的路径?以前有没有人遇到过这个问题?非常感谢.

Jua*_*ado 9

对于selenium 3.x,这Selenium::WebDriver::Chrome.driver_path = <path to chromedriver> 是不推荐使用的.现在你必须将chrome_driver路径放在驱动程序的声明中:

Capybara::Selenium::Driver.new(app, :browser => :chrome, :driver_path => <path to chromedriver>)


Tho*_*ole 5

您或者需要将驱动程序放在PATH中,或者应该能够调用

Selenium::WebDriver::Chrome.driver_path = <path to chromedriver> 
Run Code Online (Sandbox Code Playgroud)

在初始化驱动程序之前