0

Code block:

from selenium import webdriver
from selenium.webdriver.common.keys import Keys

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

new_driver_path = '/Users/username/Desktop/Python/geckodriver'
new_binary_path = '/Applications/Firefox.app/Contents/MacOS/firefox-bin'

ops = Options()
ops.binary_location = new_binary_path
serv = Service(new_driver_path)
driver = webdriver.Firefox(service=serv, options=ops)

On running the above python program i get the following error.

Traceback (most recent call last):
  File "prog.py", line 13, in <module>
driver = webdriver.Firefox(service=serv, options=ops)
  File "/usr/local/lib/python3.7/site-packages/selenium/webdriver/firefox/webdriver.py", line 174, in __init__
self.service.start()
  File "/usr/local/lib/python3.7/site-packages/selenium/webdriver/common/service.py", line 98, in start
self.assert_process_still_running()
  File "/usr/local/lib/python3.7/site-packages/selenium/webdriver/common/service.py", line 112, in assert_process_still_running
% (self.path, return_code)
selenium.common.exceptions.WebDriverException: Message: Service /Users/chetanparakh/Desktop/Python/geckodriver unexpectedly exited. Status code was: -9

I might be wrong but maybe something seems to be wrong with the new_binary_path.

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
Chetan
  • 469
  • 3
  • 12
  • 27

1 Answers1

0

This error message...

self.assert_process_still_running()
  File "/usr/local/lib/python3.7/site-packages/selenium/webdriver/common/service.py", line 112, in assert_process_still_running
% (self.path, return_code)
selenium.common.exceptions.WebDriverException: Message: Service /Users/chetanparakh/Desktop/Python/geckodriver unexpectedly exited. Status code was: -9

...implies that the previous instance of GeckoDriver is still present hence the program was unable to initiate/spawn a new GeckoDriver process.


Solution

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

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352