1

I keep getting the same error with selenium trying to control chrome.

This is my code and the error that I get. I already opened chromedriver and allowed it to be executed from the security in pref system.

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


s= Service('chromedriver')
chromeOptions = Options ()
driver = webdriver. Chrome (service=s, options=chromeOptions)
WebDriverException                        Traceback (most recent call last)
/Users/marclamy/Desktop/code/instagram_bot_detection/1_data_collection.ipynb Cell 10 in <cell line: 8>()
      6 s= Service('chromedriver')
      7 chromeOptions = Options ()
----> 8 driver = webdriver. Chrome (service=s, options=chromeOptions)

File /opt/homebrew/Caskroom/miniforge/base/envs/main_env/lib/python3.8/site-packages/selenium/webdriver/chrome/webdriver.py:69, in WebDriver.__init__(self, executable_path, port, options, service_args, desired_capabilities, service_log_path, chrome_options, service, keep_alive)
     66 if not service:
     67     service = Service(executable_path, port, service_args, service_log_path)
---> 69 super().__init__(DesiredCapabilities.CHROME['browserName'], "goog",
     70                  port, options,
     71                  service_args, desired_capabilities,
     72                  service_log_path, service, keep_alive)

File /opt/homebrew/Caskroom/miniforge/base/envs/main_env/lib/python3.8/site-packages/selenium/webdriver/chromium/webdriver.py:89, in ChromiumDriver.__init__(self, browser_name, vendor_prefix, port, options, service_args, desired_capabilities, service_log_path, service, keep_alive)
     86     raise AttributeError('service cannot be None')
     88 self.service = service
---> 89 self.service.start()
     91 try:
     92     super().__init__(
     93         command_executor=ChromiumRemoteConnection(
     94             remote_server_addr=self.service.service_url,
     95             browser_name=browser_name, vendor_prefix=vendor_prefix,
     96             keep_alive=keep_alive, ignore_proxy=_ignore_proxy),
     97         options=options)

File /opt/homebrew/Caskroom/miniforge/base/envs/main_env/lib/python3.8/site-packages/selenium/webdriver/common/service.py:98, in Service.start(self)
     96 count = 0
     97 while True:
---> 98     self.assert_process_still_running()
     99     if self.is_connectable():
    100         break

File /opt/homebrew/Caskroom/miniforge/base/envs/main_env/lib/python3.8/site-packages/selenium/webdriver/common/service.py:110, in Service.assert_process_still_running(self)
    108 return_code = self.process.poll()
    109 if return_code:
--> 110     raise WebDriverException(
    111         'Service %s unexpectedly exited. Status code was: %s'
    112         % (self.path, return_code)
    113     )

WebDriverException: Message: Service chromedriver unexpectedly exited. Status code was: -9
Marc
  • 522
  • 1
  • 5
  • 15

1 Answers1

0

We're using python's selenium's webdriver-manager to manage our driver and had this same error from this line

driver = webdriver.Chrome(ChromeDriverManager().install())

To fix it, we opened a chrome window -> settings -> about chrome -> update chrome. Or chrome://settings/help on your browser.

After it finished building the new version of chrome, that same line no longer generates the error.

Of course, this only worked since Google had pushed a new version of chrome with a bugfix for whatever was causing that.

Shili Ho
  • 51
  • 5