From the course: Learning Playwright

Unlock this course with a free trial

Join today to access over 24,800 courses taught by industry experts.

Handling cookie authentication in Playwright

Handling cookie authentication in Playwright

From the course: Learning Playwright

Handling cookie authentication in Playwright

- [Instructor] Now that we've got a few homepage tests in place, let's look at what it's like testing the system from a logged-in user's perspective. We created a login spec already, but from the last lesson, you may notice a challenge we may be facing. Every test creates a new browser context. How can we quickly and easily get our test into a logged-in state for the tests that require login? The simple answer is we just go through the login steps before each step. But this will add a lot of time to our test execution time and it'd be a lot of repeated code. Thankfully the Playwright team has built some awesome tools to help us store an authentication state, all within Playwright. When we were setting up the project section in the Playwright config file, You may remember that, with the setup project, with something we built, we'll be using this project to handle authentication within the system once, and saving the state to be used within other tests. So let's start by creating a new…

Contents