Skip to content

Commit 0fd011d

Browse files
authored
Merge pull request #352 from abhishek-lambda/AT-281
AT-281
2 parents 71e51b2 + f5d31a4 commit 0fd011d

File tree

1 file changed

+17
-14
lines changed

1 file changed

+17
-14
lines changed

accessibility/scanner/index.js

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -133,23 +133,26 @@ function processAccessibilityReport(win){
133133
});
134134
}
135135

136-
commandsToWrap.forEach((command) => {
137-
Cypress.Commands.overwrite(command, (originalFn, ...args) => {
138-
let isAccessibilityLoaded = Cypress.env("ACCESSIBILITY") || false;
139-
if (!isAccessibilityLoaded) {
140-
console.log('log', "accessibility not enabled " + isAccessibilityLoaded);
141-
return originalFn(...args);
142-
}
136+
Cypress.on('window:load', async (command) => {
137+
if(!command || !command.attributes) return;
138+
if(command.attributes.name == 'window' || command.attributes.name == 'then' || command.attributes.name == 'wrap' || command.attributes.name == 'wait') {
139+
return;
140+
}
143141

144-
console.log('log', "debugging scan for command " + command);
145-
cy.window().then((win) => {
146-
processAccessibilityReport(win);
147-
});
142+
if (!commandsToWrap.includes(command.attributes.name)) return;
143+
let isAccessibilityLoaded = Cypress.env("ACCESSIBILITY") || false;
144+
if (!isAccessibilityLoaded){
145+
console.log('log', "accessibility not enabled " + isAccessibilityLoaded);
146+
return;
147+
}
148148

149-
return originalFn(...args);
150-
});
151-
});
152149

150+
console.log('log', "debugging scan form command " + command.attributes.name);
151+
152+
cy.window().then((win) => {
153+
processAccessibilityReport(win);
154+
})
155+
})
153156

154157

155158
Cypress.on('command:end', (command) => {

0 commit comments

Comments
 (0)