Home > Mobile >  assert_process_still_running() and WebDriverException: Message: Service geckodriver unexpectedly exi
assert_process_still_running() and WebDriverException: Message: Service geckodriver unexpectedly exi

Time:02-25

I am somewhat frustrated and have already completely reinstalled my Raspberry Pi because of this issue. I can't seem to get geckodriver to work. I get the following error message.

pi@raspberrypi:~ $ python3
Python 3.9.2 (default, Mar 12 2021, 04:06:34)
[GCC 10.2.1 20210110] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from selenium import webdriver
>>> browser = webdriver.Firefox()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/pi/.local/lib/python3.9/site-packages/selenium/webdriver/firefox/webdriver.py", line 173, in __init__
    self.service.start()
  File "/home/pi/.local/lib/python3.9/site-packages/selenium/webdriver/common/service.py", line 98, in start
    self.assert_process_still_running()
  File "/home/pi/.local/lib/python3.9/site-packages/selenium/webdriver/common/service.py", line 110, in assert_process_still_running
    raise WebDriverException(
selenium.common.exceptions.WebDriverException: Message: Service geckodriver unexpectedly exited. Status code was: 1

Geckodriver Version:

pi@raspberrypi:~ $ geckodriver -v
1645706311333   webdriver::httpapi      DEBUG   Creating routes
1645706311398   geckodriver     DEBUG   Listening on 127.0.0.1:4444

PATH

pi@raspberrypi:~ $ echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/games:/usr/games

I updated raspian of course.

CodePudding user response:

This error message...

  File "/home/pi/.local/lib/python3.9/site-packages/selenium/webdriver/firefox/webdriver.py", line 173, in __init__
    self.service.start()
  File "/home/pi/.local/lib/python3.9/site-packages/selenium/webdriver/common/service.py", line 98, in start
    self.assert_process_still_running()
  File "/home/pi/.local/lib/python3.9/site-packages/selenium/webdriver/common/service.py", line 110, in assert_process_still_running
    raise WebDriverException(
selenium.common.exceptions.WebDriverException: Message: Service geckodriver unexpectedly exited. Status code was: 1

...implies that there are Zombie process of GeckoDriver still occupying your system memory.


Solution

Always invoke driver.quit() within tearDown(){} method to close & destroy the WebDriver and Web Client instances gracefully to avoid the dangling process instances.


References

You can find a couple of relevent detailed discussions in:

CodePudding user response:

Thanks @undetected Selenium for your answer.

I tried the following with my test.py

import os
import psutil

PROCNAME = "geckodriver" # or chromedriver or IEDriverServer
for proc in psutil.process_iter():
    # check whether the process name matches
    if proc.name() == PROCNAME:
            print(PROCNAME)
            proc.kill()

from selenium import webdriver
browser = webdriver.Firefox()

I'm getting the same error message:

Traceback (most recent call last):
  File "/home/pi/test.py", line 12, in <module>
    browser = webdriver.Firefox()
  File "/home/pi/.local/lib/python3.9/site-packages/selenium/webdriver/firefox/webdriver.py", line 173, in __init__
    self.service.start()
  File "/home/pi/.local/lib/python3.9/site-packages/selenium/webdriver/common/service.py", line 98, in start
    self.assert_process_still_running()
  File "/home/pi/.local/lib/python3.9/site-packages/selenium/webdriver/common/service.py", line 110, in assert_process_still_running
    raise WebDriverException(
selenium.common.exceptions.WebDriverException: Message: Service geckodriver unexpectedly exited. Status code was: 1

Do you guys know why, how can i fix this issue?

Thanks a lot!

  • Related