@@ -513,6 +513,9 @@ class Playwright extends Helper {
513513 this . frame = null
514514 this . contextLocator = null
515515
516+ // Clear popup state to ensure clean state for each test
517+ popupStore . clear ( )
518+
516519 recorder . retry ( {
517520 retries : test ?. opts ?. conditionalRetries || 3 ,
518521 when : err => {
@@ -712,17 +715,24 @@ class Playwright extends Helper {
712715 // Clear any lingering DOM timeouts by executing cleanup in browser context
713716 try {
714717 if ( this . page && ! this . page . isClosed ( ) ) {
715- await this . page . evaluate ( ( ) => {
716- // Clear any running highlight timeouts by clearing a range of timeout IDs
717- for ( let i = 1 ; i <= 1000 ; i ++ ) {
718- clearTimeout ( i )
719- }
720- } )
718+ await this . page
719+ . evaluate ( ( ) => {
720+ // Clear any running highlight timeouts by clearing a range of timeout IDs
721+ for ( let i = 1 ; i <= 1000 ; i ++ ) {
722+ clearTimeout ( i )
723+ }
724+ } )
725+ . catch ( ( ) => {
726+ // Ignore errors if execution context is destroyed (e.g., due to navigation)
727+ } )
721728 }
722729 } catch ( e ) {
723- console . warn ( 'DOM timeout cleanup warning:' , e . message )
724- this . hasCleanupError = true
725- this . testFailures . push ( `DOM cleanup failed: ${ e . message } ` )
730+ // Only log if it's not an execution context error
731+ if ( ! e . message . includes ( 'Execution context was destroyed' ) ) {
732+ console . warn ( 'DOM timeout cleanup warning:' , e . message )
733+ this . hasCleanupError = true
734+ this . testFailures . push ( `DOM cleanup failed: ${ e . message } ` )
735+ }
726736 }
727737
728738 // If we have cleanup errors, throw to fail the test suite
0 commit comments