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:
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.