指定 selenium-standalone 的 chromedriver 路径

nas*_*ras 4 javascript selenium command-line npm selenium-chromedriver

我正在尝试启动 selenium-standalone 服务器(https://www.npmjs.com/package/selenium-standalone),但它抛出了一个错误:

14:19:09 /usr/local/lib/node_modules/selenium-standalone/bin/selenium-standalone:54
14:19:09         throw err;
14:19:09               ^
14:19:09 Error: Missing /usr/local/lib/node_modules/selenium-standalone/.selenium/chromedriver/2.18-x64-chromedriver
14:19:09     at /usr/local/lib/node_modules/selenium-standalone/lib/check-paths-existence.js:15:20
14:19:09     at Object.cb [as oncomplete] (fs.js:169:19)
14:19:09 Build step 'Execute shell' marked build as failure
Run Code Online (Sandbox Code Playgroud)

selenium 服务器正在寻找路径上的 chromedriver

/usr/local/lib/node_modules/selenium-standalone/.selenium/chromedriver/2.18-x64-chromedriver

默认情况下。

是否可以在运行服务器时在命令行中指定 chromedriver 位置?就像是:

selenium-standalone -Dwebdriver.chrome.driver=<path_to_chromedriver> start
Run Code Online (Sandbox Code Playgroud)

mol*_*vec 5

有可能你需要先安装它!

?  ~ selenium-standalone install
----------
selenium-standalone installation starting
----------

---
selenium install:
from: https://selenium-release.storage.googleapis.com/2.53/selenium-server-standalone-2.53.0.jar
to: /usr/local/lib/node_modules/selenium-standalone/.selenium/selenium-server/2.53.0-server.jar
---
chrome install:
from: https://chromedriver.storage.googleapis.com/2.21/chromedriver_mac32.zip
to: /usr/local/lib/node_modules/selenium-standalone/.selenium/chromedriver/2.21-x64-chromedriver


selenium-standalone installation [==================  ] 91% 8.2s
Run Code Online (Sandbox Code Playgroud)

selenium-standalone 提供这个命令来帮助你下载和安装 chromedriver。此外,它还提供了为 selenium、chromedriver 和架构设置和下载不同选项的命令(我没有找到设置路径的命令)

# choose selenium version 
selenium-standalone install --version=2.45.0 --baseURL=https://selenium-release.storage.googleapis.com

# choose chrome driver version 
selenium-standalone install --drivers.chrome.version=2.15 --drivers.chrome.baseURL=https://chromedriver.storage.googleapis.com

# choose ie driver architecture 
selenium-standalone start --drivers.ie.arch=ia32 --drivers.ie.baseURL=https://selenium-release.storage.googleapis.com
Run Code Online (Sandbox Code Playgroud)