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

Selenium webdriver 如何在Ruby中为Jenkins服务器上运行的Cucumber设置ChromeDriver的路径?,selenium-webdriver,capybara,selenium-chromedriver,Selenium Webdriver,Capybara,Selenium Chromedriver,我使用Cucumber和Capybara在Jenkins服务器中运行自动化测试。Firefox一切正常。然而,我在安装谷歌Chrome和ChromeDriver时遇到了问题。我已经安装了Google Chrome和ChromeDriver(将ChromeDriver移动到usr/bin/ChromeDriver),但是当测试运行时,它会通知一个错误: "Unable to find the chromedriver executable. Please download the server f

我使用Cucumber和Capybara在Jenkins服务器中运行自动化测试。Firefox一切正常。然而,我在安装谷歌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." 
下面是我在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
注册驱动程序时,如何设置ChromeDriver的路径?以前有人遇到过这个问题吗?
非常感谢。

您需要将驱动程序置于路径中,或者您应该能够拨打电话

Selenium::WebDriver::Chrome.driver_path = <path to chromedriver> 
Selenium::WebDriver::Chrome.driver\u路径=

在初始化驱动程序之前,您必须下载。解压文件并将其放入路径中的任何文件夹中。简而言之,将文件移动到Ruby文件夹,可能是C:\Ruby22-x64\bin

请将chromedriver.exe放置在与Ruby.exe相同的文件夹/位置。对于selenium 3.x,这一点对我很有用。这个
selenium::WebDriver::Chrome.driver\u path=
不推荐使用。现在您必须将chrome_驱动程序路径放入驱动程序声明中:


Capybara::Selenium::Driver.new(app,:browser=>:chrome,:Driver\u path=>)

您需要将chrome驱动程序放在运行测试的机器上的
路径
变量中。。。您是否可以执行echo$PATH命令并检查chromedriver路径是否存在。As 2019也不推荐使用:不推荐使用驱动程序路径。将:service与Selenium::WebDriver::service实例一起使用。