Selenium.common.exceptions.WebDriverException: Message: unknown error: Chrome failed to start: crashed is a popular Python error which means ChromeDriver can not start a new WebBrowser session.
In this article we will detail why the error is occurring for most cases and how to get ride of it, we will include many possible solutions that you can choose from.
Describing Selenium WebDriverException Message unknown error Chrome failed to start
Sometimes, even when you install the last version of chrome or even Firefox and even when you have chromedriver installed on your computer. You just cannot get a browser instance to start.
First, let us try to replicate the error, step one is to import the webdriver using the line of code bellow.
And try opening an instance
Unfortunately, we fail to get the webpage and the result is the following error that we are trying to solve.
We will try solving the error with a couple of possible solutions that may work for you.
Solution 1 : Deleting Pycharm
Your main issue is the Chrome browser is not installed at the default location within your system.
The server i.e. ChromeDriver expects you to have Chrome installed in the default location for each system as per the image below:
The problem starts because we can not start a WebBrowser session using the ChromeDriver, the root of the issue is the fact that Chrome is not installed in the default location, it is installed but at the wrong place.
In windows the default location is the Path bellow.
In Linux, the symlink to the chrome binary is the path bellow
The easiest and shortest solution is to delete Chrome/Chromedriver/Pycharm
After that you should reinstall everything so you can avoid setting the chrome binary.
The error should be solved after these steps. If that is not the case then the solution bellow may do the trick.
Solution 2 : Overriding the location of the Chrome binary
The second solution is to override the location of the chrome binary. This can be done using Python.
Feel free to adapt the solution bellow to your needs.
I hope the solution above worked for you, if that is the case and you want to help please consider donating to our Kofi account using the red Kofi button at the top of the page.
Solution 3 : for docker and Selenium users
Another solution for developers who are running on a docker container in build environment is to get into the container.
And run the code inside the container as root.
Solution 4 : close all the tabs ( if chromeDriver is installed )
Sometimes, the thing causing the error is that you are running multiple chrome tabs at the same time.
Please close all the tabs then start the process again.
This only works if chromeDriver is installed on your machine.
Summing-up
This is the end of our article, I hope this helped you solve the error Selenium.common.exceptions.WebDriverException: Message: unknown error: Chrome failed to start: crashed or at least showed you the way. You can donate to our Kofi account but you do not Have to. Keep coding and cheers.
If you want to learn more about Python, please check out the Python Documentation : https://docs.python.org/3/