Selenium: Webdriverexception:Chrome Failed to Start: Crashed as Google-Chrome Is No Longer Running So Chromedriver Is Assuming That Chrome Has Crashed

Selenium: WebDriverException:Chrome failed to start: crashed as google-chrome is no longer running so ChromeDriver is assuming that Chrome has crashed

Try to download HERE and use this latest chrome driver version:

  • https://sites.google.com/chromium.org/driver/

Try this:

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

chrome_options = Options()
chrome_options.add_argument('--headless')
chrome_options.add_argument('--no-sandbox')
chrome_options.add_argument('--disable-dev-shm-usage')
d = webdriver.Chrome('/home/<user>/chromedriver',chrome_options=chrome_options)
d.get('https://www.google.nl/')

chromedriver is no longer running, so ChromeDriver is assuming that Chrome has crashed error using Selenium through Python

You need to take care of a couple of things as follows:

  • options.binary_location: Refers to the google-chrome binary location and is used if Google Chrome isn't installed at the default location. See: WebDriverException: unknown error: cannot find Chrome binary error with Selenium in Python for older versions of Google Chrome

  • --remote-debugging-port: If you aren't remote debugging, you can drop this argument safely.

  • chrome_driver_binary: Referes to the absolute location of the ChromeDriver within your system.

  • webdriver.Chrome(chrome_driver_binary, options = options): Additionally you may like to add the key executable_path as as follows:

    chrome_driver_binary = '/home/myname/projects/myproject/chromedriver'
    driver = webdriver.Chrome(executable_path=chrome_driver_binary, options = options)
    driver.get('http://www.ubuntu.com/')
  • --no-sandbox, --headless, --disable-dev-shm-usage, --disable-setuid-sandbox, etc are optional settings which you may not require to start off.

The minimum code block to initiate a Selenium driven ChromeDriver initiated google-chrome Browsing Context can be:

from selenium import webdriver

options = webdriver.ChromeOptions()
options.add_argument("start-maximized")
driver = webdriver.Chrome(executable_path='/home/myname/projects/myproject/chromedriver', options=options)
driver.get("http://www.ubuntu.com/")

A common cause for Chrome to crash during startup is running Chrome as root user (administrator) on Linux. While it is possible to work around this issue by passing --no-sandbox flag when creating your WebDriver session, such a configuration is unsupported and highly discouraged. You need to configure your environment to run Chrome as a regular user instead.



References

You can find a couple of relevant detailed discussions in:

  • How to configure ChromeDriver to initiate Chrome browser in Headless mode through Selenium?

WebDriverException: Message: unknown error: Chrome failed to start: exited abnormally using Selenium ChromeDriver and Chrome through WebDriverManager

You need to take care of a couple of things here as follows:

  • You need webdriver.Chrome() only once. If you don't need the arguments through Options() keep:

    driver = webdriver.Chrome(service=service)

    and remove:

    driver = webdriver.Chrome(ChromeDriverManager().install(),options=chrome_options)

    or vice versa.

  • If you are executing as a non-root using add_argument('--headless') generally you may not even require the following arguments:

    • add_argument('--no-sandbox')
    • add_argument('--disable-dev-shm-usage')
  • You can try to initiate the new Browsing Context i.e. google-chrome-headless using:

    driver = webdriver.Chrome(service=ChromeDriverManager().install(), options=chrome_options)
  • Your effective code block will be:

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

    chrome_options = Options()
    chrome_options.add_argument('--headless')
    # optional
    chrome_options.add_argument('--no-sandbox')
    # optional
    chrome_options.add_argument('--disable-dev-shm-usage')

    driver = webdriver.Chrome(ChromeDriverManager().install(),options=chrome_options)
    driver.get('http://192.168.15.1/me_configuracao_avancada.asp')

Note: Ensure that you have installed webdriver-manager and Chrome browser within your system before you kickoff your test execution.



Related Topics



Leave a reply



Submit