ruby 无法找到 chromedriver 可执行文件

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/19862276/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-06 06:17:42  来源:igfitidea点击:

Unable to find the chromedriver executable

rubyseleniumselenium-webdriverwatirselenium-chromedriver

提问by user2969455

Unable to find the chromedriver executable. Please download the server from http://code.google.com/p/chromedriver/downloads/listand place it somewhere on your PATH. More info at http://code.google.com/p/selenium/wiki/ChromeDriver. (Selenium::WebDriver::Error::WebDriverError)

无法找到 chromedriver 可执行文件。请从http://code.google.com/p/chromedriver/downloads/list下载服务器并将其放置在 PATH 中的某个位置。更多信息请访问http://code.google.com/p/selenium/wiki/ChromeDriver。(Selenium::WebDriver::Error::WebDriverError)

On Ubuntu 13 with Watir and Ruby.

在带有 Watir 和 Ruby 的 Ubuntu 13 上。

采纳答案by Nakilon

Please download the server from http://code.google.com/p/chromedriver/downloads/listand place it somewhere on your PATH. More info at https://github.com/SeleniumHQ/selenium/wiki/ChromeDriver.

请从http://code.google.com/p/chromedriver/downloads/list下载服务器并将其放置在 PATH 中的某个位置。更多信息请访问https://github.com/SeleniumHQ/selenium/wiki/ChromeDriver

UPD:Link that is not broken: https://sites.google.com/a/chromium.org/chromedriver/downloads

UPD:未损坏的链接:https: //sites.google.com/a/chromium.org/chromedriver/downloads

回答by Graham Slick

For other people on MacOS:

对于 MacOS 上的其他人:

brew cask install chromedriver

And you'll be good to go.

你会很高兴去的。

回答by ddavison

It also will work to add an environment variable named webdriver.chrome.driver.

它还可以添加一个名为 的环境变量webdriver.chrome.driver

set webdriver.chrome.driverto whatever the absolute path is.

设置webdriver.chrome.driver为任何绝对路径。

回答by Nimesh Nikum

For Linux/Ubuntu users, only running the following command should be sufficient:

对于 Linux/Ubuntu 用户,只需运行以下命令就足够了:

sudo apt-get install chromium-chromedriver 

It takes care of addition the binary file to PATH as well.

它还负责将二进制文件添加到 PATH 中。

回答by Jaswinder

I am considering Ruby on Rails features tests. Steps to add chromedriver to selenium webdrivers initialization:

我正在考虑 Ruby on Rails 功能测试。将 chromedriver 添加到 selenium webdrivers 初始化的步骤:

1) Download lastest chrome executable from https://sites.google.com/a/chromium.org/chromedriver/downloads

1) 从https://sites.google.com/a/chromium.org/chromedriver/downloads下载最新的 chrome 可执行文件

2) Declare webdriver path in rails spec helper as (For selenium 3.x)

2) 在 rails spec helper 中将 webdriver 路径声明为(对于 selenium 3.x)

Selenium::WebDriver::Chrome.driver_path = "/home/jazz/Desktop/web_drivers/chromedriver"

and this should be before driver initialization like Capybara::Selenium::Driver.new(app, :browser => :chrome)

这应该在驱动程序初始化之前 Capybara::Selenium::Driver.new(app, :browser => :chrome)

For above 3.x, just pass driver path during initialization-

对于 3.x 以上版本,只需在初始化期间传递驱动程序路径-

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

All set. Load any feature spec in rails.It will open a chrome window.

搞定。在 rails 中加载任何特性规范。它将打开一个 chrome 窗口。

回答by kai_onthereal

I have another solution worth trying:

我还有另一个值得尝试的解决方案:

in rails-helper.rbgo to this line and change :firefoxto :chrome

rails-helper.rb转到此行并更改:firefox:chrome

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

to

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

then, go to ChromeDriverand run this:

然后,转到ChromeDriver并运行:

brew tap homebrew/cask && brew cask install chromedriver

回答by barmic

I had the same issue with Ruby and Watir. I have installed ChromeDriver according to this tutorial:

我对 Ruby 和 Watir 也有同样的问题。我已经根据本教程安装了 ChromeDriver:

https://tecadmin.net/setup-selenium-chromedriver-on-ubuntu/

https://tecadmin.net/setup-selenium-chromedriver-on-ubuntu/

Then I had following error:

然后我有以下错误:

DevToolsActivePort file doesn't exist while trying to initiate Chrome Browser

In my case error was solved by adding the arguments --no-sandboxand --disable-dev-shm-usageto browser contructor:

在我的情况下,错误是通过向浏览器构造函数添加参数--no-sandbox--disable-dev-shm-usage来解决的:

args = ['--no-sandbox', '--disable-dev-shm-usage']
browser = Watir::Browser.new :chrome, options: {args: args}

Finally, everything works fine.

最后,一切正常。

回答by BlackRiver

For me what have worked was to download the chromedriver.exebased on my Chrome version and place it on my directory "C:/ruby/...bin/" I've tried to setup the environment variable but it didn't work at all.

对我来说,有效的是下载chromedriver.exe基于我的 Chrome 版本并将其放置在我的目录“C:/ruby/...bin/”中我已经尝试设置环境变量,但它根本不起作用。