OpenQA.Selenium.WebDriverException: unknown error: Chrome failed to start: exited abnormally while executing tests through Selenium start on linux
This error message...
OpenQA.Selenium.WebDriverException: unknown error: Chrome failed to start: exited abnormally
...implies that the ChromeDriver was unable to initiate/spawn a new WebBrowser i.e. Chrome Browser session.
Your main issue is the incompatibility between the version of the binaries you are using as follows:
- You are using chromedriver=2.9 which is pretty ancient.
So there is a clear mismatch between the ChromeDriver version (v2.33) and the recent Chrome Browser version (vVersion 68.0)
Solution
- Upgrade ChromeDriver to current ChromeDriver v2.41 level.
- Keep Chrome version between Chrome v67-69 levels. (as per ChromeDriver v2.41 release notes)
- Clean your Project Workspace through your IDE and Rebuild your project with required dependencies only.
- If your base Web Client version is too old, then uninstall it through Revo Uninstaller and install a recent GA and released version of Web Client.
- Execute your
@Test
.
References
You can find a couple of relevant discussions in:
- WebDriverException: Message: unknown error: Chrome failed to start: exited abnormally with ChromeDriver Chrome and Selenium on debian server
- Message: unknown error: Chrome failed to start: exited abnormally on AWS Cloud9 with Linux 4.9.85-38.58.amzn1.x86_64 x86_64
- WebDriverException: Message: unknown error: Chrome failed to start: exited abnormally with ChromeDriver Chrome and Selenium through Python on VPS
org.openqa.selenium.WebDriverException: unknown error: Chrome failed to start: crashed using ChromeDriver Selenium in Jenkins on Ubuntu 18.04
This error message...
...implies that the ChromeDriver was unable to initiate/spawn a new Browsing Context i.e. Chrome Browser session.
Deep dive
Looking into the snapshot of the error stacktrace you have provided, though you mentioned about using ChromeDriver 81.0.4044.69 and Google Chrome 81.0.4044.129, still it appears there is a mismatch between the versions of the different binaries you are using, possibly Chrome browser is not installed at the default location within your system or due to JDK mismatch. Additionally, ChromeDriver 81.0.4044.69 (2020-03-17) was a bit unstable which was replaced by ChromeDriver 81.0.4044.138 (2020-05-05)
However, the server i.e. ChromeDriver expects you to have Chrome installed in the default location for each system as per the image below:
1For Linux systems, the ChromeDriver expects /usr/bin/google-chrome
to be a symlink to the actual Chrome binary.
You can find a detailed discussion in What is default location of ChromeDriver and for installing Chrome on Windows
Solution
In case you are using the Chrome executable in a non-standard location you have to override the Chrome binary location as follows:
Code based solution:
System.setProperty("webdriver.chrome.driver", "/path/to/chromedriver");
ChromeOptions options = new ChromeOptions();
options.setBinary('/usr/bin/google-chrome'); //chrome binary location
options.addArguments("--headless");
options.addArguments("--no-sandbox");
options.addArguments("--disable-dev-shm-usage");
WebDriver driver = new ChromeDriver(options);
driver.get("https://www.google.com/");
//execute the remaining steps
driver.quit();Additional considerations- Ensure the following:
- JDK is upgraded to current levels JDK 8u251.
- Selenium is upgraded to current levels Version 3.141.59.
- ChromeDriver is updated to current ChromeDriver v81.0.4044.138 level.
- Chrome is updated to current Chrome Version 81.0.4044.138 level. (as per ChromeDriver v80.0 release notes)
- Clean your Project Workspace through your IDE and Rebuild your project with required dependencies only.
- Execute your
@Test
as non-root user. - Always invoke
driver.quit()
withintearDown(){}
method to close & destroy the WebDriver and Web Client instances gracefully.
References
You can find a couple of relevant discussions in:
- WebDriverException: unknown error: DevToolsActivePort file doesn't exist while trying to initiate Chrome Browser
- How to configure ChromeDriver to initiate Chrome browser in Headless mode through Selenium?
- Running Chromedriver on Ubuntu Server headlessly
Related Topics
Overloaded Method-Group Argument Confuses Overload Resolution
C# Arrow Key Input for a Console App
Crud Operations Using Datagridview, Datatable and Dataadapter - Cannot Add New Row to Datagridview
Wpf Openfiledialog with the Mvvm Pattern
Will the Base Class Constructor Be Automatically Called
Get Current Url in a Blazor Component
Any Way to Turn the "Internet Off" in Windows Using C#
Windows Forms Graphic Issue on Windows 10 Os
Play Multiple Sounds Using Soundplayer
How to Convert Hex to a Byte Array
Xml Deserialization of Collection Property with Code Defaults
Better Way to Cast Object to Int
How to Read Data from Excel File Using C#
This Row Already Belongs to Another Table Error When Trying to Add Rows