@@ -197,8 +197,9 @@ class _AccessibilityHandler {
197197 . forEach ( ( command ) => {
198198 const browser = this . _browser as WebdriverIO . Browser
199199 try {
200+ const prevImpl = browser [ command . name as keyof WebdriverIO . Browser ] . bind ( browser )
200201 // @ts -expect-error fix type
201- browser . overwriteCommand ( command . name , this . commandWrapper . bind ( this , command ) , command . class === 'Element' )
202+ browser . overwriteCommand ( command . name , this . commandWrapper . bind ( this , command , prevImpl ) , command . class === 'Element' )
202203 } catch ( error ) {
203204 BStackLogger . debug ( `Exception in overwrite command ${ command . name } - ${ error } ` )
204205 }
@@ -364,7 +365,7 @@ class _AccessibilityHandler {
364365 * private methods
365366 */
366367
367- private async commandWrapper ( command : { name : string , class : string } , origFunction : Function , ...args : string [ ] ) {
368+ private async commandWrapper ( command : { name : string , class : string } , prevImpl : Function , origFunction : Function , ...args : string [ ] ) {
368369 if (
369370 this . _sessionId && AccessibilityHandler . _a11yScanSessionMap [ this . _sessionId ] &&
370371 (
@@ -375,7 +376,7 @@ class _AccessibilityHandler {
375376 BStackLogger . debug ( `Performing scan for ${ command . class } ${ command . name } ` )
376377 await performA11yScan ( this . isAppAutomate , this . _browser , true , true , command . name )
377378 }
378- return origFunction ( ...args )
379+ return prevImpl ( ...args )
379380 }
380381
381382 private async sendTestStopEvent ( browser : WebdriverIO . Browser , dataForExtension : unknown ) {
0 commit comments