Playwright · Middle · Question 13 of 75

How do you test with two different roles in one test, e.g. admin and user?

Show the answer

Correct answer: Create two browser contexts, each with its own storageState

Explanation

Each context is isolated, so browser.newContext({ storageState: 'admin.json' }) and a user context can act side by side, like two people in a chat.

Further reading

Problem with a question

Playwright · Middle · question 13

Test yourself

Take the Playwright · Middle quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz