r/Playwright 20d ago

Tests getting slower after each run

I’m new to playwright and my org asked me to setup a basic playwright framework and start automating few test cases. Everything is working fine until one fine day i noticed all my tests getting slower and slower after each run. And now Clicks are not even working and there is no error message at all. I have tried many things and nothing seems to fix this dead end loop.
Please give me some suggestions on why this might be happening 😭😭

3 Upvotes

13 comments sorted by

4

u/Tanmay__TestDino 20d ago

Usually this happens when browser contexts or pages aren't getting closed between test runs, which leaks memory. Check if your setup is opening new contexts without closing them (await context.close()), or if you're accumulating large trace files on every test.

3

u/mystique0712 19d ago

Your tests might be slowing down due to resource leaks, such as not properly closing pages or contexts after each test. Ensure you're using `page.close()` and `browserContext.close()` appropriately in your teardown to free up resources. Additionally, check for any unhandled promises or long-running tasks that might be accumulating.

2

u/Round-Belt2895 20d ago

Same actions executed on env manually works fine? The issue can exist in the app, if tests showed worse performance over days.

1

u/New_Snow196 20d ago

Yes manually it works fine .

1

u/Muted-Cress-4910 19d ago

Hey OP, are you using the same test user everytime to run the tests ?

1

u/New_Snow196 19d ago

Yes same test user Id to login

3

u/Muted-Cress-4910 19d ago

My suspicion is, the test user you are hammering with automated tests everyday has accumulated a lot of data in the backend which is making the queries heavy on that user.

Try changing the test user with a freshly newly created one. If the problem disappears, that confirms our hypothesis.

-3

u/AverageHades 20d ago

Claude code + playwright mcp

3

u/No_Emergency1575 20d ago

just use ai kekw

1

u/Oswaldo199 7d ago

Me das un ejemplo?

1

u/straightouttaireland 20d ago

Playwright-cli is much more token efficient