@@ -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
155158Cypress . on ( 'command:end' , ( command ) => {
0 commit comments