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.

Browser launch and context arguments

Browser launch and context arguments

In this section, we have learned about the different fixtures our plugin provides. That is the browser, browser context, the page, and so on. Now when we get the browser, we don't get to configure its launch options. The same goes for our new context. That is, we cannot define the arguments which are used to create the same. In this lesson, we'll go ahead and take a look, how to pass arguments when we launch our browser, and create new context. To do that, we have to use a fixture, which will be used by our plugin. That fixture will return the arguments as a dictionary. So let's go ahead and import playwright, import pytest, and then we can go ahead and define a fixture that is pytest.fixture and the name of the fixture to give arguments to our browser launch. We can use browser underscore type underscore launch underscore args. Now because this fixture is a session scope, we have to define the same here as well. is scope of this fixture is session. Now we can go ahead and return a…

Contents