@@ -207,11 +207,12 @@ describe('Playwright', function () {
207207 await I . waitToHide ( 'h9' )
208208 } )
209209
210- it ( 'should wait for invisible combined with dontseeElement' , async ( ) => {
210+ it ( 'should wait for invisible combined with dontseeElement' , async function ( ) {
211+ this . timeout ( 30000 ) // Increase timeout for external URL test
211212 await I . amOnPage ( 'https://codecept.io/' )
212- await I . waitForVisible ( '.frameworks' )
213- await I . waitForVisible ( '[alt="React"]' )
214- await I . waitForVisible ( '.mountains' )
213+ await I . waitForVisible ( '.frameworks' , 10 )
214+ await I . waitForVisible ( '[alt="React"]' , 10 )
215+ await I . waitForVisible ( '.mountains' , 10 )
215216 await I . _withinBegin ( '.mountains' , async ( ) => {
216217 await I . dontSeeElement ( '[alt="React"]' )
217218 await I . waitForInvisible ( '[alt="React"]' , 2 )
@@ -1624,3 +1625,34 @@ describe('using data-testid attribute', () => {
16241625 assert . equal ( webElements . length , 1 )
16251626 } )
16261627} )
1628+
1629+ // Global after hook to ensure all browser instances are closed
1630+ after ( async function ( ) {
1631+ this . timeout ( 10000 ) // 10 second timeout for cleanup
1632+
1633+ // Close the main browser instance if it exists
1634+ if ( I && I . browser ) {
1635+ try {
1636+ await Promise . race ( [ I . browser . close ( ) , new Promise ( ( _ , reject ) => setTimeout ( ( ) => reject ( new Error ( 'Browser close timeout' ) ) , 5000 ) ) ] )
1637+ } catch ( e ) {
1638+ console . warn ( 'Warning during browser cleanup:' , e . message )
1639+ }
1640+ }
1641+
1642+ // Close remote browser if it exists
1643+ if ( remoteBrowser ) {
1644+ try {
1645+ await Promise . race ( [ remoteBrowser . close ( ) , new Promise ( ( _ , reject ) => setTimeout ( ( ) => reject ( new Error ( 'Remote browser close timeout' ) ) , 5000 ) ) ] )
1646+ } catch ( e ) {
1647+ console . warn ( 'Warning during remote browser cleanup:' , e . message )
1648+ }
1649+ }
1650+
1651+ // Force close any remaining Playwright browser processes
1652+ try {
1653+ const { exec } = await import ( 'child_process' )
1654+ exec ( 'pkill -f "playwright.*chromium" || true' )
1655+ } catch ( e ) {
1656+ // Ignore errors from pkill
1657+ }
1658+ } )
0 commit comments