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.

Session scope fixtures

Session scope fixtures

In this lesson, we'll cover the session scope fixtures which are only created once and provided to all of the test functions. Now we have already made use of the browser fixture which is launched once and provided to all of the test functions. It is the type of browser and we can use the same to let's say create a new page without a browser context. Now if I go ahead and request for a browser in the second test function as well, it will be the same browser we get in the first test function. So a session scope fixture is only created once and provided to all of the test functions repeatedly. Now we can go ahead and get the playwright instance as well, using the playwright fixture, which is the type of playwright. You can also get the browser type, which is browser underscore type. And the type of this is browser type. Now you can use this to assert or check what is the type of browser we are running on. is you can check if the browser type is equals playwright dot chromium then you can…

Contents