Skip to content
This repository was archived by the owner on Mar 19, 2021. It is now read-only.

Commit d625312

Browse files
authored
fix: Improve error message when an iframe was removed (#118)
1 parent cddebec commit d625312

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

lib/axe-injector.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
const { StaleElementReferenceError } = require('selenium-webdriver').error;
2+
13
class AxeInjector {
24
constructor({ driver, config, axeSource = null }) {
35
this.driver = driver;
@@ -9,15 +11,20 @@ class AxeInjector {
911
}
1012

1113
// Single-shot error handler. Ensures we don't log more than once.
12-
errorHandler() {
14+
errorHandler(err) {
1315
// We've already "warned" the user. No need to do it again (mostly for backwards compatiability)
1416
if (this.didLogError) {
1517
return;
1618
}
1719

1820
this.didLogError = true;
19-
// eslint-disable-next-line no-console
20-
console.error('Failed to inject axe-core into one of the iframes!');
21+
if (err instanceof StaleElementReferenceError) {
22+
// eslint-disable-next-line no-console
23+
console.error('Tried to inject into a removed iframe. This will not affect the analysis of the rest of the page but you might want to ensure the page has finished updating before starting the analysis.')
24+
} else {
25+
// eslint-disable-next-line no-console
26+
console.error('Failed to inject axe-core into one of the iframes!');
27+
}
2128
}
2229

2330
// Get axe-core source (and configuration)

0 commit comments

Comments
 (0)