Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(cli): better error message for ChromeDriver version mismatch #680

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.)`);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"the first number" is a bit ambiguous. We should be very specific about what we want as browser version 114.0.5735.198 the first number would be 1 which would not be the version of chromedriver we want.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're confusing "digit" with "number". I changed your suggestion of "major version" to "first number of the version" since I think there's a good chance that the user isn't familiar with SemVer.

process.exit(2);
} else {
throw e;
}
Expand Down