1

I'm trying to debug why my selenium won't work. I've been looking through Heroku docs for how to handle using a selenium webdriver when deployed to Heroku, but I've encountered this bug recently:

Traceback (most recent call last):
  File "C:\Users\IanMurray\Documents\acis\selenium_sandbox.py", line 13, in <module>
    driver = webdriver.Chrome(
  File "C:\Users\IanMurray\Documents\acis\.venv3.9\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 49, in __init__
    super().__init__(
  File "C:\Users\IanMurray\Documents\acis\.venv3.9\lib\site-packages\selenium\webdriver\chromium\webdriver.py", line 54, in __init__
    super().__init__(
  File "C:\Users\IanMurray\Documents\acis\.venv3.9\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 206, in __init__
    self.start_session(capabilities)
  File "C:\Users\IanMurray\Documents\acis\.venv3.9\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 291, in start_session
    response = self.execute(Command.NEW_SESSION, caps)["value"]
  File "C:\Users\IanMurray\Documents\acis\.venv3.9\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 346, in execute
    self.error_handler.check_response(response)
  File "C:\Users\IanMurray\Documents\acis\.venv3.9\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 245, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: unknown error: Failed to create Chrome process.
Stacktrace:
Backtrace:
GetHandleVerifier [0x0115A813+48355]
        (No symbol) [0x010EC4B1]
        (No symbol) [0x00FF5358]
        (No symbol) [0x01012026]
        (No symbol) [0x01010579]
        (No symbol) [0x01040C55]
        (No symbol) [0x0104093C]
        (No symbol) [0x0103A536]
        (No symbol) [0x010182DC]
        (No symbol) [0x010193DD]
        GetHandleVerifier [0x013BAABD+2539405]
        GetHandleVerifier [0x013FA78F+2800735]
        GetHandleVerifier [0x013F456C+2775612]
        GetHandleVerifier [0x011E51E0+616112]
        (No symbol) [0x010F5F8C]
        (No symbol) [0x010F2328]
        (No symbol) [0x010F240B]
        (No symbol) [0x010E4FF7]
        (No symbol) [0x75EE00C9]
        RtlGetAppContainerNamedObjectPath [0x77927B4E+286]
        RtlGetAppContainerNamedObjectPath [0x77927B1E+238]

I am initializing my webdriver with the following code. It is a minimal example to reproduce the bug on my machine:

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

service = Service(ChromeDriverManager().install())
options = webdriver.ChromeOptions()
options.add_argument('--no-sandbox')
options.add_argument('--disable-dev-shm-usages')
options.add_argument('--headless')
options.add_argument('--remote-debugging-port=9222')

driver = webdriver.Chrome(
    service=service,
    options=options
)

print("done")

Running the above code without the "driver = webdriver.Chrome(service, options)" line runs fine, but there's no webdriver initialized. As soon as I try running "driver = webdriver.Chrome()", even without the service/options parameters, I get the following error as well.

I'm on Python 3.9.13, with selenium version: 4.10.0. Please let me know if you need any more information from me. Thanks in advance for any help. The version of Chrome I am using is: 114.0.5735.134, and the ChromeDriver version I am using is: ChromeDriver 114.0.5735.90

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
Ian Murray
  • 65
  • 6

1 Answers1

1

Update to Selenium v4.10.0 so you so won't explicitly need WebDriverManager, as Selenium Manager being fully integrated is invoked transparently by the Selenium bindings when no browser driver is detected on the PATH or no third party driver manager is being used.

Additionally instead of:

options.add_argument('--headless')

Use the argument --headless=new:

options.add_argument("--headless=new");

Solution

Your effective code block will be:

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

options = webdriver.ChromeOptions()
options.add_argument('"--headless=new"')
driver = webdriver.Chrome(options=options)
print("done")
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
  • 1
    hi undetected Selenium, thanks for your help. Running the above code verbatim yields the same error. My selenium version is exactly 4.10.0, so it should have the features you mentioned. I will keep trying things until something works, and write back with any progress – Ian Murray Jun 20 '23 at 18:25
  • 1
    @IanMurray Let me know if you need further help anytime in the [Selenium](https://chat.stackoverflow.com/rooms/223360/selenium) room. – undetected Selenium Jun 20 '23 at 18:26