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 selection

Browser selection

In the previous lesson, we learned about the session scope fixtures like the browser name and its Firefox, which can be used to determine the type of our browser. In the first test, I'm going ahead and making sure that the browser is not equals to Firefox. If that's the case, only then I go ahead and run the test. So I am skipping this test based on the Firefox browser. Opposite to that, in the second test I am running this test only if it is Firefox. Now the pytest plugin provides a better way to handle this using pytest decorators. So I can go ahead and import pytest like this. Then in this function we need to skip the Firefox browser. do that, I can use pytest.mark.skip browser like this. I can give this decorator the browser I want to skip, which in this case is Firefox. I can go ahead and remove the fixture usage like this. Similarly, for this test, we have to do the opposite, that is, we want to only run if it is firefox. Again we use pytest dot mark and only browser decorator…

Contents