mediumConceptDesignMidSenior
How do you get a browser test into the state it needs to start, without clicking through the UI to get there?
6 min readUpdated 2026-08-15Target archetype: Big Tech, Enterprise Captive, Product Startup
Answer
Short answer
Create the data through the API, restore an authenticated session from saved cookies and storage rather than logging in each time, and stub only the third parties you do not own, so each test drives the UI solely for the behaviour it is actually asserting.
Was this answer helpful?
Likely follow-ups
- Your saved session expires halfway through a suite run. How should the setup handle that?
- Where does the login flow itself get tested once every other test skips it?
- A stubbed response drifts from what the real endpoint returns. How would you find out before your users do?
- Which parts of setup would you deliberately keep slow and realistic, and why?
Related questions
- What does auto-waiting do in Playwright and Cypress, how do the two differ architecturally, and what can neither of them test?mediumAlso on playwright and cypress6 min
- When do you scale out instead of up, and what does that force you to change?mediumAlso on session-state6 min
- A Playwright test clicks a button that is visibly on screen, and roughly one run in twenty nothing happens. The button is server-rendered but the app hydrates after load. Why does the click get lost, and how do you fix the flake properly?mediumAlso on playwright4 min
- A flash sale decrements stock from many threads. Do you go optimistic or pessimistic, and how do you prove nothing oversold?mediumSame kind of round: design5 min