← Back to Discord Forum

Browser close interrupting afterEach (help ASAP!!!)

EDIT: Solved.

I'm running automated UI tests for an eCommerce site, and most of my files have cleanup functions in the afterEach section so that past tests (especially failed ones) don't mess up future tests. Today my test runs started failing because Playwright would invariably close the browser in the middle of one of those cleanup functions. I've checked all over my code and I don't see anything that would interrupt the test, and I don't think this is a timeout issue because my timeouts are super long (for database reasons) and I'm not seeing any timeout messages, just "browser context closed" ones. Help???

This thread is trying to answer question "How can I resolve an issue where the browser closes in the middle of a cleanup function in an automated UI test?"

7 replies

Have you missed an await for any of your async cleanup routines?

Well, slap me in the face 🤣 Not only did I miss the await, but I was looking at the wrong file while debugging.

The file I checked had nothing wrong with it, but it wasn't relevant anyway.

How do I put a "solved" tag on this again?


Haha, we've all been there! Staring at the same problem too long melts the brain 😂


Hmm not sure, maybe edit the original post?

I couldn't see any option for that so I just... edited

AboutQuestionsDiscord ForumBrowser ExtensionTagsQA Jobs

Rayrun is a community for QA engineers. I am constantly looking for new ways to add value to people learning Playwright and other browser automation frameworks. If you have feedback, email luc@ray.run.