OpenQA.Selenium.WebDriverException: unknown error: Chrome failed to start: exited abnormally while executing tests through Selenium start on Linux
Asked Answered
A

2

4

I created an application that use Selenium using .NetCore for use on Linux. This is my code implementation:

public class Program 
{
    public static async Task Main(string[] args)
    {
        //Settings for chrome
        var chromeOpts = new ChromeOptions();
        chromeOpts.AddArgument("headless");
        chromeOpts.AddArgument("no-sandbox");

        //Get assembly path where chrome driver is located
        string codeBase = Assembly.GetExecutingAssembly().CodeBase;
        UriBuilder uri = new UriBuilder(codeBase);
        string path = Uri.UnescapeDataString(uri.Path);
        path = Path.GetDirectoryName(path);

        var driver = new ChromeDriver(path, chromeOpts, TimeSpan.FromSeconds(180));
    }
}

As you can see, I am using as driver Chrome. I downloaded it here. I also added the driver inside the folder of the assembly. In this way the ChromeDriver knows already where to find it.

On Linux I changed the folder permission using chmod -R 777 but, when I run my Dotnet application, I get this:

enter image description here

Seems that Selenium cannot start the application. Looking at the Exception I get:

Cannot find Chrome binary

Unfortunately I didn't find anything similar on the web.

UPDATE

I reinstalled Chrome on my Linux machine and now the error above went away, but there is another problem now. I get this error:

OpenQA.Selenium.WebDriverException: unknown error: Chrome failed to start: exited abnormally  (Driver info: chromedriver=2.9.248304,platform=Linux 4.4.0-130-generic x86_64)   
  at OpenQA.Selenium.Remote.RemoteWebDriver.UnpackAndThrowOnError(Response errorResponse)   
  at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters)   
  at OpenQA.Selenium.Remote.RemoteWebDriver.StartSession(ICapabilities desiredCapabilities)   
  at OpenQA.Selenium.Remote.RemoteWebDriver..ctor(ICommandExecutor commandExecutor, ICapabilities desiredCapabilities)   
  at OpenQA.Selenium.Chrome.ChromeDriver..ctor(ChromeDriverService service, ChromeOptions options, TimeSpan commandTimeout)   
  at OpenQA.Selenium.Chrome.ChromeDriver..ctor(String chromeDriverDirectory, ChromeOptions options, TimeSpan commandTimeout)\   at ODS.Program.Main(String[] args)
Andria answered 7/8, 2018 at 6:52 Comment(2)
Update the question with text based error trace logsEquation
@DebanjanB I added itAndria
E
2

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:

Equation answered 7/8, 2018 at 7:13 Comment(1)
I can't believe, this working and were I was wrong was here: chromedriver.storage.googleapis.com/index.html infact I downloaded the version 2.9 (I though that the version with the largest number are the recent version). Anyway, on the site that you linked to me the recent is 2.41, so this is really weird. What do you think about this? Anyway, thanks for this solution you have helped me a lot, have a good day!Andria
M
0

first, check your google-chrome version then download related chromedriver version i.eenter image description here

Menticide answered 9/6, 2022 at 5:23 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.