带有geckodriver的Firefox不会在Ubuntu服务器上启动



我有 Ubuntu Server 19.04 64 位。我使用以下软件包:

  • NodeJS v10.16.0
  • 火狐浏览器 68.0.1

我在节点.js项目中安装了selenium-webdriver ^4.0.0-alpha.4

我还使用以下算法安装了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/

我的项目有索引.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:我尝试了壁虎驱动程序的最新版本,并得到了:

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

您需要更新您的 Firefox 浏览器,这可能是因为 GeckoDriver 和 Firefox 浏览器不匹配而发生的。

如果这也不起作用,请使用以下版本的壁虎驱动程序,请尝试使用壁虎驱动程序的第二个和第三个更新版本。

没有推荐,您仍然可能需要降级浏览器并尝试最新版本或尝试使用壁虎驱动程序的第二个和第三个更新版本。 之后,当二进制可用于最新的Firefox版本时,您应该尝试使用最新版本进行更新

这也是您的壁虎驱动程序

没有退出并且它仍然在后面运行以抑制要打开的新会话的可能性之一,您可以使用下面的文章来杀死您的壁虎驱动程序进程

https://www.tecmint.com/find-and-kill-running-processes-pid-in-linux/

因此,在对不同版本的壁虎驱动程序和 farefox 进行了长时间的测试后,我解决了我的问题!

我只是试图将 farefox 降级到 v57.0,但我没有尝试使用较新的版本。我偷使用壁虎驱动程序 0.24.0。

有关降级的更多信息,请点击此处 https://askubuntu.com/questions/661186/how-to-install-previous-firefox-version

最新更新