GVKun编程网logo

WebDriverException:即使'geckodriver'可执行文件也必须位于PATH中(只有可执行文件可以创建快捷方式)

15

在这里,我们将给大家分享关于WebDriverException:即使'geckodriver'可执行文件也必须位于PATH中的知识,让您更了解只有可执行文件可以创建快捷方式的本质,同时也会涉及到如何

在这里,我们将给大家分享关于WebDriverException:即使'geckodriver'可执行文件也必须位于PATH中的知识,让您更了解只有可执行文件可以创建快捷方式的本质,同时也会涉及到如何更有效地Firefox Geckodriver 问题 - INTERNALERROR>....WebDriverException:消息:TypeError:browsingContext.currentWindowGlobal 为空、Mac上的Python中的Selenium-Geckodriver可执行文件必须位于PATH中、node.js – 错误:驱动程序可执行文件的路径必须由webdriver.chrome.driver系统属性设置、PHP-错误:驱动程序可执行文件的路径必须由webdriver.gecko.driver系统属性设置的内容。

本文目录一览:

WebDriverException:即使'geckodriver'可执行文件也必须位于PATH中(只有可执行文件可以创建快捷方式)

WebDriverException:即使'geckodriver'可执行文件也必须位于PATH中(只有可执行文件可以创建快捷方式)

试图让Firefox在spyder中使用硒运行。我当前的代码是

from selenium import webdriverimport osos.environ["PATH"] += ":/usr/local/bin/geckodriver"browser = webdriver.Firefox()

我仍然收到此错误:

runfile(''/Users/mherl/Dropbox/AnacondaProjects/MWS/MWSSpyder/test.py'', wdir=''/Users/mherl/Dropbox/AnacondaProjects/MWS/MWSSpyder'')Traceback (most recent call last):  File "<ipython-input-1-3f3f96ccf515>", line 1, in <module>runfile(''/Users/mherl/Dropbox/AnacondaProjects/MWS/MWSSpyder/test.py'', wdir=''/Users/mherl/Dropbox/AnacondaProjects/MWS/MWSSpyder'')  File "/Applications/anaconda3/lib/python3.6/site-   packages/spyder/utils/site/sitecustomize.py", line 705, in runfile  execfile(filename, namespace)  File "/Applications/anaconda3/lib/python3.6/site-   packages/spyder/utils/site/sitecustomize.py", line 102, in execfile    exec(compile(f.read(), filename, ''exec''), namespace)  File "/Users/mherl/Dropbox/AnacondaProjects/MWS/MWSSpyder/test.py", line 12, in <module>  browser = webdriver.Firefox()  File "/Applications/anaconda3/lib/python3.6/site- packages/selenium/webdriver/firefox/webdriver.py", line 152, in __init__self.service.start()  File "/Applications/anaconda3/lib/python3.6/site- packages/selenium/webdriver/common/service.py", line 83, in startos.path.basename(self.path), self.start_error_message)WebDriverException: ''geckodriver'' executable needs to be in PATH.

即使gekodriver在该文件夹中。

证明gekodriver位置正确

我也尝试过将路径导出到〜。/ bash_profile,现在看起来像这样。

Last login: Fri Apr 20 10:57:16 on ttys000dhcp-54-85:~ mherl$ nano ./bash_profiledhcp-54-85:~ mherl$ nano .bash_profile  GNU nano 2.0.6             File: .bash_profile                      Modified# Setting PATH for Python 3.6# The original version is saved in .bash_profile.pysavePATH="/Library/Frameworks/Python.framework/Versions/3.6/bin:${PATH}"export PATH# Setting PATH for Python 3.6# The original version is saved in .bash_profile.pysavePATH="/Library/Frameworks/Python.framework/Versions/3.6/bin:${PATH}"export PATH# added by Anaconda3 5.1.0 installerexport PATH="/Applications/anaconda3/bin:$PATH"#added by mherl to show path to gekodriverexport PATH=$PATH:/usr/local/bin/gekodriver

我还在spyder中设置了当前路径:

/usr/local/bin/Users/mherl/Dropbox/AnacondaProjects/MWS/MWSSpyder

gekodriver在其中

/usr/local/bin

我到处都看过,大多数人说如果它位于/ usr / local / bin中,它应该自动运行,但是即使我
明确声明了路径,它仍然似乎找不到。

如果重要的话,这是一台运行High Sierra的Mac。

答案1

小编典典

这个错误讯息…

WebDriverException: ''geckodriver'' executable needs to be in PATH.

…意味着在预期的默认 位置找不到GeckoDriver

当您使用基于MAC系统,你需要通过按键executable_path与沿值指的是绝对路径的的GeckoDriver如下:

from selenium import webdriverbrowser = webdriver.Firefox(executable_path=''/usr/local/bin/geckodriver'')

Additional Consideration

Ensure the following :

  • GeckoDriver is present in the specified location.
  • GeckoDriver is having executable permission for non-root users.
  • Execute your @Test as a non-root user.

Firefox Geckodriver 问题 - INTERNALERROR>....WebDriverException:消息:TypeError:browsingContext.currentWindowGlobal 为空

Firefox Geckodriver 问题 - INTERNALERROR>....WebDriverException:消息:TypeError:browsingContext.currentWindowGlobal 为空

如何解决Firefox Geckodriver 问题 - INTERNALERROR>....WebDriverException:消息:TypeError:browsingContext.currentWindowGlobal 为空?

我的套件适用于 Chrome 和 Edge,但不适用于 Firefox。它开始并突然结束。

尝试了不同版本的 geckodriver (32/64),更新的 firefox 浏览器 - 没有运气

日志: Image with logs

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

Mac上的Python中的Selenium-Geckodriver可执行文件必须位于PATH中

Mac上的Python中的Selenium-Geckodriver可执行文件必须位于PATH中

我是编程的新手,大约2个月前开始使用Python,现在正在研究Sweigart的《用Python文本自动完成无聊的事情》。我正在使用Spyder
3,并且已经安装了selenium模块和Firefox浏览器。我在python文件中使用了以下代码

from selenium import webdriverbrowser = webdriver.Firefox()browser.get(''http://inventwithpython.com'')

我收到此错误:

Message: ''geckodriver'' executable needs to be in PATH.

除了进入终端并使用进行安装外,我还下载了geckodriver.exe。

brew install geckodriver

奇怪的是,如果我进入终端并输入“
python”,然后将代码放入,它可以工作,但是当我在Spyder中运行文件时却不能。我需要将geckodriver.exe文件放在哪里才能正常工作?我尝试将其放在各种文件夹中(与python文件相同的文件夹,与webdriver文件相同的文件夹,在用户bin中,依此类推),但出现相同的错误

我看过类似的问题,但似乎找不到有效的方法。我也尝试过使用Chrome,但使用chromedriver却遇到了相同的错误。

which geckodriver

产量 /usr/local/bin/geckodriver

我也在Mac上,因此文件路径比Windows困难。

答案1

小编典典

已解决:我将geckodriver exe放在/ Users / sethkillian / anaconda /
bin中,现在可以从Spyder正常使用了。谢谢您的帮助!

node.js – 错误:驱动程序可执行文件的路径必须由webdriver.chrome.driver系统属性设置

node.js – 错误:驱动程序可执行文件的路径必须由webdriver.chrome.driver系统属性设置

我正在尝试 node.js selenium web driver example …

var webdriver = require('selenium-webdriver');

var driver = new webdriver.Builder().
   usingServer('http://localhost:4444/wd/hub').
   withCapabilities(webdriver.Capabilities.chrome()).
   build();

driver.get('http://www.google.com');
driver.findElement(webdriver.By.name('q')).sendKeys('webdriver');
driver.findElement(webdriver.By.name('btnG')).click();
driver.wait(function() {
 return driver.getTitle().then(function(title) {
   return title === 'webdriver - Google Search';
 });
},1000);

driver.quit();

…但是有错误

promise.js:1542
      throw error;
            ^
UnkNownError: The path to the driver executable must be set by the webdriver.chrome.driver system property; for more information,see http://code.google.com/p/selenium/wiki/ChromeDriver. The latest version can be downloaded from http://code.google.com/p/chromedriver/downloads/list
    at new bot.Error (/Users/maks/DropBox/nodeApps/orgi/node_modules/selenium-webdriver/lib/atoms/error.js:109:18)

我guessed设置PATH变量:

$ cat .bashrc

export PATH=$PATH:/usr/local/git/bin/
export PATH=$PATH:~/bin
export PATH=$PATH:~/DropBox/chromedriver

并重新启动控制台,但得到相同的错误。

解决方法

从 here使用selenium-server-standalone – *。jar启动它时,可以传递webdriver.chrome.driver属性:

java -jar selenium-server-standalone-2.35.0.jar -Dwebdriver.chrome.driver="D:\dev\chromedriver.exe"

这消除了错误; Java命令行选项-Dproperty = value按预期设置系统属性值。

PHP-错误:驱动程序可执行文件的路径必须由webdriver.gecko.driver系统属性设置

PHP-错误:驱动程序可执行文件的路径必须由webdriver.gecko.driver系统属性设置

我正在使用PHP进行自动化功能单元测试.我想使用PHPStorm在登台环境上运行测试,并且我关注以下链接:https://www.sitepoint.com/using-selenium-with-phpunit/.我有完整的任务,直到以下代码:
我已经访问了此链接,但不适用于我. The path to the driver executable must be set by the webdriver.gecko.driver system property

<?PHP

/**
 * Created by PHPStorm.
 * User: Developer4
 * Date: 11/2/2016
 * Time: 1:41 PM
 */
class uatTest extends PHPUnit_Extensions_Selenium2TestCase
{
    public function setUp()
    {
        $this->setHost('localhost');
        $this->setPort(4444);
        $this->setbrowserUrl('https://www.facebook.com/');

        $this->setbrowser('firefox');
    }
    public function tearDown()
    {
        $this->stop();
    }
    public function validInputsProvider()
    {
        $inputs[] = [
            [
                'email'              => 'user',
                'pass'              => 'pass'
            ]
        ];
        return $inputs;
    }
    public function testFormSubmissionWithUsername()
    {
        $this->byName('email')->value('user');
        $this->byId('loginbutton')->submit();
        $email = $this->byName('email');
        $this->assertEquals('user', $email->value());
    }
}

当我的硒服务器正在运行时:

enter image description here

当我在PHPstorm上运行测试时,出现此错误

enter image description here

错误:

C:\wamp\bin\PHP\PHP5.6.25\PHP.exe C:/wamp/www/PHPUnit-and-Composer-Workflow/vendor/PHPunit/PHPunit/PHPunit --no-configuration uatTest C:\wamp\www\PHPUnit-and-Composer-Workflow\test\uatTest.PHP --teamcity
Testing started at 2:53 PM ...
PHPUnit 5.6.2 by Sebastian Bergmann and contributors.


The path to the driver executable must be set by the webdriver.gecko.driver system property; for more information, see https://github.com/mozilla/geckodriver. The latest version can be downloaded from https://github.com/mozilla/geckodriver/releases
 C:\wamp\www\PHPUnit-and-Composer-Workflow\vendor\PHPunit\PHPunit-selenium\PHPUnit\Extensions\Selenium2TestCase\Driver.PHP:165
 C:\wamp\www\PHPUnit-and-Composer-Workflow\vendor\PHPunit\PHPunit-selenium\PHPUnit\Extensions\Selenium2TestCase\Driver.PHP:72
 C:\wamp\www\PHPUnit-and-Composer-Workflow\vendor\PHPunit\PHPunit-selenium\PHPUnit\Extensions\Selenium2TestCase\SessionStrategy\Isolated.PHP:67
 C:\wamp\www\PHPUnit-and-Composer-Workflow\vendor\PHPunit\PHPunit-selenium\PHPUnit\Extensions\Selenium2TestCase.PHP:296
 C:\wamp\www\PHPUnit-and-Composer-Workflow\vendor\PHPunit\PHPunit-selenium\PHPUnit\Extensions\Selenium2TestCase.PHP:337
 C:\wamp\www\PHPUnit-and-Composer-Workflow\vendor\PHPunit\PHPunit-selenium\PHPUnit\Extensions\Selenium2TestCase.PHP:314



Time: 823 ms, Memory: 3.50MB


ERRORS!
Tests: 1, Assertions: 0, Errors: 1.

Process finished with exit code 2

并在cmd上得到理解:

enter image description here

解决方法:

这是解决方案:

    java -Dwebdriver.gecko.driver="C:\Users\Developer4\Downloads\geckodriver-v0.11.1-win32\geckodriver.exe" -jar C:\wamp\bin\PHP

\PHP5.6.25\selenium-server-standalone-3.0.1.jar

关于WebDriverException:即使'geckodriver'可执行文件也必须位于PATH中只有可执行文件可以创建快捷方式的问题就给大家分享到这里,感谢你花时间阅读本站内容,更多关于Firefox Geckodriver 问题 - INTERNALERROR>....WebDriverException:消息:TypeError:browsingContext.currentWindowGlobal 为空、Mac上的Python中的Selenium-Geckodriver可执行文件必须位于PATH中、node.js – 错误:驱动程序可执行文件的路径必须由webdriver.chrome.driver系统属性设置、PHP-错误:驱动程序可执行文件的路径必须由webdriver.gecko.driver系统属性设置等相关知识的信息别忘了在本站进行查找喔。

本文标签: