当前位置: 首页 > 知识库问答 >
问题:

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

井宪
2023-03-14

我正在尝试Node.js selenium web驱动程序示例...

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)
$ cat .bashrc

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

共有1个答案

盖和泰
2023-03-14

从这里使用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按照预期设置系统属性值。

 类似资料: