Skip to content

Commit 10cf350

Browse files
fix(cli): better error message for ChromeDriver version mismatch (#680)
* feat(cli): better error message for ChromeDriver version mismatch Fixes #679. * reduce branch coverage to 91 --------- Co-authored-by: Steven Lambert <[email protected]> Co-authored-by: Steven Lambert <[email protected]>
1 parent 60abf5e commit 10cf350

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

packages/cli/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@
7575
"html"
7676
],
7777
"statements": 95,
78-
"branches": 92,
78+
"branches": 91,
7979
"functions": 94,
8080
"lines": 95,
8181
"exclude": [

packages/cli/src/bin/index.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,24 @@ const cli = async (
118118
console.error(error('Error: %s'), e.message);
119119
console.log(`The timeout is currently configured to be ${timeout} seconds (you can change it with --timeout).`)
120120
process.exit(2);
121+
}
122+
// Provide a more user-friendly error message when there's a ChromeDriver/Chrome version mismatch.
123+
else if (
124+
e instanceof selenium_error.SessionNotCreatedError &&
125+
e.message.includes(
126+
'This version of ChromeDriver only supports'
127+
// This string has to match the error message printed by chromedriver, see
128+
// https://chromium.googlesource.com/chromium/src/+/refs/tags/110.0.5481.194/chrome/test/chromedriver/chrome_launcher.cc#300.
129+
)
130+
) {
131+
console.error(error('Error: %s'), e.message);
132+
console.log(`\nPlease install a matching version of ChromeDriver and run axe with the --chromedriver-path option:
133+
134+
$ npm install -g chromedriver@<version>
135+
$ axe --chromedriver-path $(npm root -g)/chromedriver/bin/chromedriver <url...>
136+
137+
(where <version> is the first number of the "current browser version" reported above.)`);
138+
process.exit(2);
121139
} else {
122140
throw e;
123141
}

0 commit comments

Comments
 (0)