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

后端 未结 11 706
一整个雨季
一整个雨季 2020-11-22 11:04

Server: Raspberry Pi 3
OS: Dietpi - version 159
Geckodriver version: 0.22 for arm
Firefox version: 52.9.0
Python version: 3.5
Selenium version: 3.14.1 <

相关标签:
11条回答
  • 2020-11-22 11:10

    Thumb rule

    A common cause for Browsers to crash during startup is running WebDriver initiated Browsers as root user (administrator) on Linux. While it is possible to work around this issue by passing --no-sandbox flag when creating your WebDriver session, such a configuration is unsupported and highly discouraged. You need to configure your environment to run Browser as a regular user instead.


    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.

    GeckoDriver, Selenium and Firefox Browser compatibility chart

    0 讨论(0)
  • 2020-11-22 11:14

    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

    0 讨论(0)
  • 2020-11-22 11:17

    As Nico and jay have stated you need to check the logs to see the details of the error. As you might use different systems, you can specify the path where the log is stored (i.e. "/tmp/geckodriver.log").

    from selenium import webdriver
    firefox_options = webdriver.firefox.webdriver.Options()
    driver = webdriver.Firefox(log_path="/tmp/geckodriver.log", 
                               options=firefox_options)
    

    In my particular case, what the log said was:

    Error: no DISPLAY environment variable specified

    That was resolved adding in the options the headless mode before starting the driver. With the line:

    firefox_options.set_headless()
    
    0 讨论(0)
  • 2020-11-22 11:18

    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.

    0 讨论(0)
  • 2020-11-22 11:19

    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

    0 讨论(0)
  • 2020-11-22 11:20

    in my case, I was running test cases as root

    geckodriver.log

    1576076416677   mozrunner::runner       INFO    Running command: "/usr/bin/firefox" "-marionette" "-foreground" "-no-remote" "-profile" "/tmp/rust_mozprofilenCbl2e"
    Running Firefox as root in a regular user's session is not supported.  ($HOME is /home/seluser which is owned by seluser.)
    1576077143004   mozrunner::runner       INFO    Running command: "/usr/bin/firefox" "-marionette" "-foreground" "-no-remote" "-profile" "/tmp/rust_mozprofile7wpSQ7"
    1576077143689   addons.webextension.screenshots@mozilla.org     WARN    Loading extension 'screenshots@mozilla.org': Reading manifest: Invalid extension permission: mozillaAddons
    1576077143689   addons.webextension.screenshots@mozilla.org     WARN    Loading extension 'screenshots@mozilla.org': Reading manifest: Invalid extension permission: telemetry
    1576077143689   addons.webextension.screenshots@mozilla.org     WARN    Loading extension 'screenshots@mozilla.org': Reading manifest: Invalid extension permission: resource://pdf.js/
    1576077143689   addons.webextension.screenshots@mozilla.org     WARN    Loading extension 'screenshots@mozilla.org': Reading manifest: Invalid extension permission: about:reader*
    1576077145372   Marionette      INFO    Listening on port 35571
    1576077145423   Marionette      WARN    TLS certificate errors will be ignored for this session
    1576077200207   mozrunner::runner       INFO    Running command: "/usr/bin/firefox" "-marionette" "-foreground" "-no-remote" "-profile" "/tmp/rust_mozprofilenhoHlr"
    Running Firefox as root in a regular user's session is not supported.  ($HOME is /home/seluser which is owned by seluser.)
    

    i could get around by

    cd /home
    chown -R  root seluser
    

    i woundnt say its correct but it got my job done

    0 讨论(0)
提交回复
热议问题