@@ -133,26 +133,42 @@ function processAccessibilityReport(win){
133133 } ) ;
134134}
135135
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- }
141-
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- }
148-
149-
150- console . log ( 'log' , "debugging scan form command " + command . attributes . name ) ;
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+ // }
141+ //
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+ // }
148+ //
149+ //
150+ // console.log('log', "debugging scan form command " + command.attributes.name);
151+ //
152+ // cy.window().then((win) => {
153+ // processAccessibilityReport(win);
154+ // });
155+ // })
156+
157+ // Ensure scan runs AFTER visit completes
158+ Cypress . Commands . overwrite ( 'visit' , ( originalFn , url , options ) => {
159+ return originalFn ( url , options ) . then ( ( ) => {
160+ let isAccessibilityLoaded = Cypress . env ( "ACCESSIBILITY" ) || false ;
161+ if ( ! isAccessibilityLoaded ) {
162+ console . log ( 'log' , "Accessibility not enabled." ) ;
163+ return ;
164+ }
151165
152- cy . window ( ) . then ( ( win ) => {
153- processAccessibilityReport ( win ) ;
154- } )
155- } )
166+ cy . window ( ) . then ( ( win ) => {
167+ console . log ( 'log' , "Running accessibility scan after visit: " + url ) ;
168+ processAccessibilityReport ( win ) ;
169+ } ) ;
170+ } ) ;
171+ } ) ;
156172
157173
158174Cypress . on ( 'command:end' , ( command ) => {
0 commit comments