WebDriverException: Message: invalid argument: can't kill an exited process with GeckoDriver, Selenium and Python on RaspberryPi3

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-26 15:31:17

This error message...

selenium.common.exceptions.WebDriverException: Message: invalid argument: can't kill an exited process

...implies that the GeckoDriver was unable to initiate/spawn a new WebBrowsing Session i.e. Firefox Browser session.

Your main issue is the incompatibility between the version of the binaries you are using as follows:

  • Your GeckoDriver version is 0.22.0.
  • Release Notes of GeckoDriver v0.21.0 (2018-06-15) clearly mentions the following:

    • Firefox 57 (and greater)

    • Selenium 3.11 (and greater)

  • Your Firefox version is 52.9.0.

So there is a clear mismatch between GeckoDriver v0.22.0 and the Firefox Browser v57

Solution

  • Upgrade GeckoDriver to GeckoDriver v0.22.0 level.
  • GeckoDriver is present in the specified location.
  • GeckoDriver is having executable permission for non-root users.
  • Upgrade Firefox version to Firefox v62.0.2 levels.
  • Clean your Project Workspace through your IDE and Rebuild your project with required dependencies only.
  • If your base Web Client version is too old, then uninstall it through Revo Uninstaller and install a recent GA and released version of Web Client.
  • Execute your Selenium Test as a non-root user.

If you are running Firefox on a system with no display, make sure you use headless mode.

from selenium import webdriver
from selenium.webdriver.firefox.options import Options

options = Options()
options.headless = True
driver = webdriver.Firefox(options=options)

Also, make sure you have compatible versions of Firefox, Selenium, and Geckodriver: https://firefox-source-docs.mozilla.org/testing/geckodriver/geckodriver/Support.html

Yes checked Start Xvfb before the build can fix the problem, but if you have a job like a pipeline or multibranch pipeline this option is not visible. In the node of your Selenium grid that you go to execute the test you need:

1- Install Xvfb: apt install xvfb

2- Execute Xvfb: /usr/bin/Xvfb :99 -ac -screen 0 1024x768x8 & export DISPLAY=":99"

3- Rerun your node, for example: java -jar selenium.jar -role node -hub http://#.#.#.#:4444/grid/register -capabilities browserName=firefox,plataform=linux -host #.#.#.# -port 1991

Rogelio

I was on headless mode, using correct versions of everything, and the only way to get out of this error message was not to execute the selenium test as root

I used:

  • VS Code
  • Linunx/Ubuntu:18.10
  • Nightwatch.js

My problem was that I tried to run Nightwatch (which automatically starts GeckoDriver) from the VS Code terminal.

I was able to fix this by running my tests with Xvfb. I was running them on a remote server.

I was using Jenkins so I checked the box that looked like this:

Credit to https://www.obeythetestinggoat.com/book/chapter_CI.html

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!