如何在 Ruby 中的 Jenkins 服务器上为 Cucumber 运行 设置 ChromeDriver 的路径?
How to set Path to ChromeDriver for Cucumber running on Jenkins server in Ruby?
我在 Jenkins 服务器中使用 Cucumber 和 Capybara 运行 自动化测试。 Firefox 一切正常。但是,我在设置 Google Chrome 和 Chrome 驱动程序时遇到了问题。我已经安装了 Google Chrome 和 Chrome 驱动程序(将 chromedriver 移至 usr/bin/chromedriver)但是当测试 运行s 时,它会提示错误:
"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
如何在 register_driver 时设置 Chrome 驱动程序的路径?以前有人遇到过这个问题吗?
非常感谢。
您需要将驱动程序放在 PATH 中,或者您应该能够调用
Selenium::WebDriver::Chrome.driver_path = <path to chromedriver>
在初始化驱动程序之前
您必须下载 ChromeDriver。解压缩文件并将其放入 PATH 中的任何文件夹中。总之,将文件移动到Ruby文件夹,大概是C:\Ruby22-x64\bin
请将 chromedriver.exe 与 ruby.exe 放在相同的 folder/location 中。这对我有用
对于 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>)
我在 Jenkins 服务器中使用 Cucumber 和 Capybara 运行 自动化测试。 Firefox 一切正常。但是,我在设置 Google Chrome 和 Chrome 驱动程序时遇到了问题。我已经安装了 Google Chrome 和 Chrome 驱动程序(将 chromedriver 移至 usr/bin/chromedriver)但是当测试 运行s 时,它会提示错误:
"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
如何在 register_driver 时设置 Chrome 驱动程序的路径?以前有人遇到过这个问题吗? 非常感谢。
您需要将驱动程序放在 PATH 中,或者您应该能够调用
Selenium::WebDriver::Chrome.driver_path = <path to chromedriver>
在初始化驱动程序之前
您必须下载 ChromeDriver。解压缩文件并将其放入 PATH 中的任何文件夹中。总之,将文件移动到Ruby文件夹,大概是C:\Ruby22-x64\bin
请将 chromedriver.exe 与 ruby.exe 放在相同的 folder/location 中。这对我有用
对于 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>)