From the course: Playwright Python and Pytest for Web Automation Testing: Master Modern Web Testing with Playwright and Pytest in Python

Unlock this course with a free trial

Join today to access over 25,200 courses taught by industry experts.

Project setup

Project setup

In this lesson, we'll go ahead and set up our project that is starting with a blank Python file. I'll go ahead and import Playwrights, Synchronous API, and then using with context manager, we will instantiate Playwright and manage its lifecycle, which is like the bare minimum to get started. And then we can create a browser, which will be, let's say Firefox, and let's launch it in the headed mode, though set headless as false. And now we can go ahead and load in the authentication state, which we stored in the previous section. That is this one right here. So if you have skipped the previous section, go ahead and watch it now, else let's load it in using our browser context. So browser, new context, I'll provide the storage state as plywright.auth and the storage state json. Let's format it into a new line, so it's nice and tidy. And now we can go ahead and set the page that is using our new context. Let's create a new page. And finally, the last step for our setup is to go ahead and…

Contents