Skip to content

Commit

Permalink
fix(cli): better error message for ChromeDriver version mismatch (#680)
Browse files Browse the repository at this point in the history
* feat(cli): better error message for ChromeDriver version mismatch

Fixes #679.

* reduce branch coverage to 91

---------

Co-authored-by: Steven Lambert <2433219+straker@users.noreply.github.com>
Co-authored-by: Steven Lambert <steven.lambert@deque.com>
  • Loading branch information
3 people committed Aug 22, 2023
1 parent 60abf5e commit 10cf350
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
"html"
],
"statements": 95,
"branches": 92,
"branches": 91,
"functions": 94,
"lines": 95,
"exclude": [
Expand Down
18 changes: 18 additions & 0 deletions packages/cli/src/bin/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,24 @@ const cli = async (
console.error(error('Error: %s'), e.message);
console.log(`The timeout is currently configured to be ${timeout} seconds (you can change it with --timeout).`)
process.exit(2);
}
// Provide a more user-friendly error message when there's a ChromeDriver/Chrome version mismatch.
else if (
e instanceof selenium_error.SessionNotCreatedError &&
e.message.includes(
'This version of ChromeDriver only supports'
// This string has to match the error message printed by chromedriver, see
// https://chromium.googlesource.com/chromium/src/+/refs/tags/110.0.5481.194/chrome/test/chromedriver/chrome_launcher.cc#300.
)
) {
console.error(error('Error: %s'), e.message);
console.log(`\nPlease install a matching version of ChromeDriver and run axe with the --chromedriver-path option:
$ npm install -g chromedriver@<version>
$ axe --chromedriver-path $(npm root -g)/chromedriver/bin/chromedriver <url...>
(where <version> is the first number of the "current browser version" reported above.)`);
process.exit(2);
} else {
throw e;
}
Expand Down

0 comments on commit 10cf350

Please sign in to comment.