Q&A
How do you handle multiple authenticated user roles in a single Playwright test?
Ajitesh MohantaAmbassador
2w ago 503 0
I'm writing a test for an admin action that should be visible to admins but hidden from regular users. The test needs to:
1. Log in as admin, perform an action
2. Verify as a regular user that the result is visible correctly
3. Verify as another regular user that restricted parts are hidden
Using `browser.newContext()` with different `storageState` files seems like the right approach but I'm unsure how to structure this cleanly in a fixture. Do you use separate browser contexts within one test, or separate tests linked by shared state?