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.

Function scope fixtures

Function scope fixtures

Up until now, we have used the page fixture inside of our test cases, i.e. we request for a page fixture and got the same inside of our test function. In this section, we'll go ahead and learn about all the fixtures that our playwright plugin has available for us. Now the page object, i.e. the page fixture is a functions code fixture which will be given to each function as a new page object. That is in this function we get a new page, and in the second function we again get a new page. That's why we have to start from the scratch, that is visiting the page, then creating the links, and so on. Now of course we can just use test hooks, and automate this for each test, but that's a different topic. In this one we we are focusing on functions code fixtures. Now we already know about the page fixture. We also have another fixture, which is the browser context. You can just use context as the argument name and request for the browser context. Now I can go ahead and import its type as well…

Contents