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
Changes from 1 commit
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
27 changes: 26 additions & 1 deletion packages/cli/src/bin/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
import axeTestUrls from '../lib/axe-test-urls';
import event from '../lib/events';
import { startDriver } from '../lib/webdriver';
import { error as selenium_error } from 'selenium-webdriver';

const cli = async (
args: OptionValues,
Expand Down Expand Up @@ -107,7 +108,31 @@ const cli = async (
disable
};
try {
const outcome = await axeTestUrls(urls, testPageConfigParams, events);
let outcome;
try {
outcome = await axeTestUrls(urls, testPageConfigParams, events);
} catch (e) {
// Provide a more user-friendly error message when there's a ChromeDriver/Chrome version mismatch.
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;
}
}
if (silentMode) {
process.stdout.write(JSON.stringify(outcome, null, 2));
return;
Expand Down