gpt4 book ai didi

node.js - 错误 : The path to the driver executable must be set by the webdriver. chrome.driver 系统属性

转载 作者:IT老高 更新时间:2023-10-28 22:04:08 24 4
gpt4 key购买 nike

我正在尝试 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 按预期设置系统属性值。

关于node.js - 错误 : The path to the driver executable must be set by the webdriver. chrome.driver 系统属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18272468/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com