我有 Ubuntu 服务器 19.04 64 位。我使用以下软件包:
- nodejs v10.16.0
- 火狐 68.0.1
我安装selenium-webdriver ^4.0.0-alpha.4
在我的 node.js 项目中。
我还安装geckodriver 0.24.0
了以下算法:
sudo wget https://github.com/mozilla/geckodriver/releases/download/v0.24.0/geckodriver-v0.24.0-linux64.tar.gz
tar -xvzf geckodriver-v0.24.0-linux64.tar.gz
chmod +x geckodriver
sudo mv geckodriver /usr/local/bin/
我的项目有 index.js 和以下代码:
const {Builder, By, Key, util} = require("selenium-webdriver");
const firefox = require('selenium-webdriver/firefox');
async function example() {
let options = await new firefox.Options()
.headless();
let driver = await new Builder().forBrowser("firefox").setFirefoxOptions(options).build();
await driver.get("https://mobile.facebook.com");
await driver.close();
}
example();
当我使用命令启动脚本时,sudo node index.js
出现以下错误:
(node:1303) UnhandledPromiseRejectionWarning: WebDriverError: invalid argument: can't kill an exited process
at Object.throwDecodedError (/var/nodejs/sites/test/node_modules/selenium-webdriver/lib/error.js:550:15)
at parseHttpResponse (/var/nodejs/sites/test/node_modules/selenium-webdriver/lib/http.js:560:13)
at Executor.execute (/var/nodejs/sites/test/node_modules/selenium-webdriver/lib/http.js:486:26)
at process._tickCallback (internal/process/next_tick.js:68:7)
(node:1303) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:1303) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
错误:invalid argument: can't kill an exited process
,我不知道如何解决这个问题...如果您需要有关我的情况的更多信息,请问我,我会尽力回答。
UPD:我尝试了最新版本的 geckodriver 并查看了我得到的结果:
0.24.0:WebDriverError: invalid argument: can't kill an exited process
0.23.0:WebDriverError: invalid argument: can't kill an exited process
0.22.0:WebDriverError: invalid argument: can't kill an exited process
0.21.0:WebDriverError: Process unexpectedly closed with status 1
0.20.1:WebDriverError: Process unexpectedly closed with status 1
0.20.0:WebDriverError: Process unexpectedly closed with status 1
...