Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Playwright debug test to not close browser

I'm using playwright and vscode, especially the "debug test" function which pops up a real browser window to run the test. When it fails the test auto closes, how can I make it not auto close so that I can modify the test and also visually see what the state of the test is?

like image 625
Harry Avatar asked May 01 '26 09:05

Harry


1 Answers

I think how they managed it is a disaster if compared with cypress. If they would have added a simple option in config files (as cypress does) everything would have been much easier.

Anyway, you have to use one of these solutions, not nice, but working: you have to add at the end of the last function executed one of the following

  • await this.page.waitForTimeout(120000); // will close the browser after 120 seconds
  • await new Promise(() => {}) // will stay open forever until timeout occurs, usually 120 seconds
like image 68
Don Diego Avatar answered May 04 '26 16:05

Don Diego



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!