Skip to content

Commit 5528656

Browse files
authored
ci: resolve chromedrivers not running in Ubuntu runners >=24.04 (#1150)
This patch adds `--no-sandbox` chrome flag allowing CI to pass in runners using >= Ubuntu 24.04 Resolves this [error](https://github.com/dequelabs/axe-core-npm/actions/runs/12889457050/job/36296592750#step:6:403): > SessionNotCreatedError: session not created: probably user data directory is already in use, please specify a unique value for --user-data-dir argument, or don't use --user-data-dir Related issues: SeleniumHQ/selenium#14609 No QA required
1 parent d0f62a9 commit 5528656

File tree

4 files changed

+18
-18
lines changed

4 files changed

+18
-18
lines changed

packages/cli/src/lib/webdriver.test.ts

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -90,30 +90,17 @@ describe('startDriver', () => {
9090
assert.equal(chromedriverPath, config.chromedriverPath);
9191
});
9292

93-
it('passes the --no-sandbox argument to chromeOptions', async () => {
94-
browser = 'chrome-headless';
95-
config.chromeOptions = ['--no-sandbox'];
96-
driver = await startDriver(config);
97-
98-
const options = config?.builder?.getChromeOptions();
99-
assert.isArray(options?.get('goog:chromeOptions').args);
100-
assert.deepEqual(options?.get('goog:chromeOptions').args, [
101-
'headless',
102-
'--no-sandbox'
103-
]);
104-
});
105-
10693
it('passes multiple arguments argument to chromeOptions', async () => {
10794
browser = 'chrome-headless';
108-
config.chromeOptions = ['no-sandbox', 'disable-dev-shm-usage'];
95+
config.chromeOptions = ['disable-dev-shm-usage'];
10996
driver = await startDriver(config);
11097

11198
const options = config?.builder?.getChromeOptions();
11299
assert.isArray(options?.get('goog:chromeOptions').args);
113100
assert.deepEqual(options?.get('goog:chromeOptions').args, [
114101
'headless',
115-
'no-sandbox',
116-
'disable-dev-shm-usage'
102+
'disable-dev-shm-usage',
103+
'no-sandbox'
117104
]);
118105
});
119106

packages/cli/src/lib/webdriver.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ const startDriver = async (
3535

3636
if (CHROME_TEST_PATH) {
3737
options.setChromeBinaryPath(path.resolve(CHROME_TEST_PATH));
38+
// Required for CI runners using >=Ubuntu 24.04
39+
// @see https://github.com/SeleniumHQ/selenium/issues/14609
40+
options.addArguments('no-sandbox');
3841
}
3942

4043
if (config.chromePath) {

packages/webdriverio/test/axe-webdriverio.spec.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,12 @@ describe('@axe-core/webdriverio', () => {
119119
capabilities: {
120120
browserName: 'chrome',
121121
'goog:chromeOptions': {
122-
args: ['--headless'],
122+
args: [
123+
'--headless',
124+
// Required for CI runners using >=Ubuntu 24.04
125+
// @see https://github.com/SeleniumHQ/selenium/issues/14609
126+
'--no-sandbox'
127+
],
123128
binary: process.env.CHROME_TEST_PATH as string
124129
}
125130
},

packages/webdriverjs/test/test-utils.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,12 @@ export const Webdriver = (): WebDriver => {
2323
// Weird type change since 4.23.1 release
2424
// @see https://github.com/DefinitelyTyped/DefinitelyTyped/discussions/69724
2525
const options = new chrome.Options();
26-
options.addArguments('headless');
26+
options
27+
.addArguments('headless')
28+
// Required for CI runners using >=Ubuntu 24.04
29+
// @see https://github.com/SeleniumHQ/selenium/issues/14609
30+
.addArguments('no-sandbox');
31+
2732
options.setBinaryPath(process.env.CHROME_TEST_PATH as string);
2833

2934
const builder = new Builder()

0 commit comments

Comments
 (0)