Ruby selenium webdriver 无法找到 Mozilla geckodriver

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/41310586/
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-03 08:58:07  来源:igfitidea点击:

Ruby selenium webdriver unable to find Mozilla geckodriver

ruby-on-railsrubybashseleniumubuntu-16.04

提问by user2968505

I have geckodriver installed in my development directory

我的开发目录中安装了 geckodriver

ls | grep geckodriver
geckodriver
geckodriver-v0.11.1-linux64.tar.gz

I also exported to the $PATH variable

我也导出到 $PATH 变量

export PATH=$PATH:~/Development/geckodriver

But when I attempt to initialize an instance of the webdriver on rails console of my project I get this

但是当我尝试在我的项目的 rails 控制台上初始化 webdriver 的一个实例时,我得到了这个

driver = Selenium::WebDriver.for :firefox

Selenium::WebDriver::Error::WebDriverError: Unable to find Mozilla geckodriver. Please download the server from https://github.com/mozilla/geckodriver/releasesand place it somewhere on your PATH. More info at https://developer.mozilla.org/en-US/docs/Mozilla/QA/Marionette/WebDriverWhat's the issue here.

驱动程序 = Selenium::WebDriver.for :firefox

Selenium::WebDriver::Error::WebDriverError:无法找到 Mozilla geckodriver。请从https://github.com/mozilla/geckodriver/releases下载服务器并将其放在 PATH 中的某个位置。更多信息请访问https://developer.mozilla.org/en-US/docs/Mozilla/QA/Marionette/WebDriver这里有什么问题。

回答by karthick nagarajan

You have selenium-webdriver-3.0.0.beta3.1which is only for Firefox 48 and later (and not yet properly working). Fallback to selenium-webdriverversion 2.53.4and try again.

您拥有selenium-webdriver-3.0.0.beta3.1的仅适用于 Firefox 48 及更高版本(尚未正常工作)。回退到selenium-webdriver版本并重2.53.4试。

And also try this..

也试试这个..

  • In the terminal change directory path to the directory where gem was installed
  • Run gem uninstall selenium-webdriver
  • Run gem install selenium-webdriver -v 2.53.4
  • 在终端中将目录路径更改为安装 gem 的目录
  • gem uninstall selenium-webdriver
  • gem install selenium-webdriver -v 2.53.4

回答by gabeodess

You have to make sure that geckodriveris in your PATH.

你必须确保它geckodriver在你的PATH.

In my case you can see that /usr/local/binis already in my path:

就我而言,您可以看到它/usr/local/bin已经在我的路径中:

$echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/git/bin:/usr/local/mysql/bin

So simply moving geckodriverinto /usr/local/binmakes it accessible.

因此,只需geckodriver进入/usr/local/bin即可访问。

mv geckodriver /usr/local/bin/

回答by radoAngelov

You can now move toselenium-webdriver 3.4.3which is the latest version. However, you still need the GeckoDriver because there no native extensions of Selenium in FF. You can also add the geckodriver-helpergem to your GemFile. Check https://github.com/DevicoSolutions/geckodriver-helper.

您现在可以移动到selenium-webdriver 3.4.3最新版本。但是,您仍然需要 GeckoDriver,因为 FF 中没有 Selenium 的本机扩展。您还可以将geckodriver-helpergem添加到您的 GemFile。检查https://github.com/DevicoSolutions/geckodriver-helper

Be aware of that there are still some issues that have to be fixed when you use the combination of Selenium3 & FF48+combination and can affect your tests like double-click and modal windows.

请注意,当您使用Selenium3 和 FF48+组合时,仍有一些问题需要修复,并且可能会影响您的测试,例如双击和模态窗口。

回答by Wladimir Gramacho

Download geckodriver and add it to your PATH

下载 geckodriver 并将其添加到您的 PATH

cd ~/Downloads/
wget https://github.com/mozilla/geckodriver/releases/download/v0.24.0/geckodriver-v0.24.0-linux64.tar.gz
tar -zxvf geckodriver-v0.24.0-linux64.tar.gz
sudo mv geckodriver /usr/local/bin/


Note: That's currently the path for the latest release. If you need another release, modify the download path accordingly.

注意:这是当前最新版本的路径。如果您需要另一个版本,请相应地修改下载路径。

回答by user3320949

Works for me if I add this part to the command: PATH=$PATH:/home/username/folder/driver cucumber features/new.feature

如果我将此部分添加到命令中,则对我有用: PATH=$PATH:/home/username/folder/driver cucumber features/new.feature