0

I'm trying to run a test script in Azure DevOps pipelines and I've been struggling to get selenium to run Chrome. I always get the following error:

WebDriverError: unknown error: Chrome failed to start: crashed.
(unknown error: DevToolsActivePort file doesn't exist)

I've looked at many similar questions but no luck. This only happens on Azure DevOps pipelines. It works on my local and if I login into the server and locate the source code from the build agent, I can run "npm run test" successfully.

Here is the detailed error log from Azure DevOps:

Error Log

Below is the JavaScript code that is triggered when running the script:

const { Given, When, Then, AfterAll } = require('@cucumber/cucumber');
const { until, Builder, By, Capabilities } = require('selenium-webdriver');
const { expect } = require('chai');

// WebDriver Setup (for Chrome)
const capabilities = Capabilities.chrome();

const chrome = require('selenium-webdriver/chrome');
const chromeService = chrome.setDefaultService(new chrome.ServiceBuilder('chromedriver.exe').build())
const options = new chrome.Options();
options.addArguments('--headless');
options.addArguments('--no-sandbox');
options.addArguments('--disable-dev-shm-usage');
const driver = new Builder().withCapabilities(capabilities)
                            .setChromeOptions(options)
                            .setChromeService(chromeService)
                            .build();

Also, both chrome driver and the browser are using the same version.

Thanks for your help.

Muhi
  • 116
  • 1
  • 4
  • It seems that you are using self-hosted agent, could you try it with hosted agent and share the result and ChromeDriver version here? – Vito Liu Feb 17 '21 at 03:08
  • Hi, Just checking in to see whether this issue is still blocking you now? Any update for this issue? – Vito Liu Feb 19 '21 at 08:54
  • Hi Vito, sorry for the late response. Yes we use a self-hosted agent but I will talk to the server admin to see if we can try a hosted agent instead. Thanks for your help. – Muhi Feb 20 '21 at 15:52

1 Answers1

0

According to the error message:

WebDriverError: unknown error: Chrome failed to start: crashed.
(unknown error: DevToolsActivePort file doesn't exist)

(The process started from chrome location C:\Program Files(x86)\Google\Chrome\Application\chrome.exe  is no longer running)

It implies that the ChromeDriver was unable to initiate/spawn a new WebBrowser i.e. Chrome Browser session.

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:

enter image description here

You could check this ticket for more details.

Vito Liu
  • 7,525
  • 1
  • 8
  • 17
  • Hi Vito, thanks for your response. I don't have much control over where I can install chrome on the server but if I override the Chrome binary location, as part of the solution from the ticket you provided, I still get the same error. This is my JavaScript code: options.setChromeBinaryPath('C://Program Files (x86)//Google//Chrome//Application//chrome.exe') – Muhi Feb 20 '21 at 15:47