top | item 46968103

(no title)

benoau | 19 days ago

I think testing via browser automation is fantastic, API-driven web browsers are just amazing tools, but it's also the source of a lot of the flakiness because of the inherent difficulties determining when a page is completely in a state that it can do what you're expecting of it. Playwright improves a lot on this over Puppeteer but it's imperfect, I often end up with a wait for a selector, load state, or function evaluating when it's actually okay to proceed and sometimes I'll use a combination to really make sure, because what it's really waiting for is not just achieving some state but what actually happens after it does.

discuss

order

forcepushed|17 days ago

Yes, exactly how most of experience here goes. Each test ends up becoming sort of a custom implementation to handle specific use cases around interactivity and availability.

Do you feel yourself wanting to extract this logic (wait for a selector, load state, or function evaluating etc) to some shared utility and then just pushing all of your interactions through this as a sort of feedback engine for future problems?

benoau|14 days ago

> to some shared utility and then just pushing all of your interactions through this

Yeah that's basically what Playwright is doing under the hood, your click is more like "wait for the element to exist and then click". Back in my puppeteer days I'd usually have my own click/etc functions wrapping everything in a try/catch and retrying.

It's very hard to balance because ultimately the solution is basically always waiting <arbitrary ms> after any interaction and that itself is dependent on how busy the CPU is which varies between local vs CI, and you blow up your running time by setting like "slowMo" to 100ms for example.