diff --git a/packages/cli/package.json b/packages/cli/package.json index 4e87abea..7fef3338 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -75,7 +75,7 @@ "html" ], "statements": 95, - "branches": 92, + "branches": 91, "functions": 94, "lines": 95, "exclude": [ diff --git a/packages/cli/src/bin/index.ts b/packages/cli/src/bin/index.ts index e60357ca..695094af 100644 --- a/packages/cli/src/bin/index.ts +++ b/packages/cli/src/bin/index.ts @@ -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@ + $ axe --chromedriver-path $(npm root -g)/chromedriver/bin/chromedriver + +(where is the first number of the "current browser version" reported above.)`); + process.exit(2); } else { throw e; }