Forums

Selenium Webdriver Error

Hello

I'm trying to test running headless chrome using selenium and am running into an error

selenium.common.exceptions.WebDriverException: Message: unknown error: Chrome failed to start: exited abnormally.
  (unknown error: DevToolsActivePort file doesn't exist)
  (The process started from chrome location /usr/bin/chromium is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
Stacktrace:
#0 0x563bfaa91e89 <unknown>

Im using python 3.10 and have upgraded selenium

Here is my test code

from selenium import webdriver
from selenium.webdriver.chrome.options import Options
options = Options()
options.add_argument('--headless=new')
options.add_argument('--disable-gpu')
driver = webdriver.Chrome(chrome_options=options)

Thanks for the help

I think you need the --no-sandbox flag too -- see this help page for some sample Selenium code.

Thank you for the suggestion, unfortunately I am receiving the same error

selenium.common.exceptions.WebDriverException: Message: unknown error: Chrome failed to start: exited abnormally.
  (unknown error: DevToolsActivePort file doesn't exist)
  (The process started from chrome location /usr/bin/chromium is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
Stacktrace:
#0 0x55bd8e92ee89 <unknown>



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

    options = Options()
    # options.add_argument("start-maximized")
    options.add_argument('--headless=new')
    # options.add_experimental_option("excludeSwitches", ["enable-automation"])
    # options.add_experimental_option('useAutomationExtension', False)
    # options.add_argument('--disable-3d-apis')
    options.add_argument('--disable-gpu')
    options.add_argument('--no-sandbox-')
    options.add_argument('--disable-dev-shm-usage')
    driver = webdriver.Chrome(chrome_options=options)
    try:
        driver.get("https://www.google.com")
        print("Page title was '{}'".format(driver.title))
    finally:
    driver.quit()

It looks like there's a hyphen at the end of your --no-sandbox flag