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.

Using fixture

Using fixture

In the previous lesson, we created our report json fixture. Now in this lesson, we'll see how to use the same inside of our test functions. Now you may be tempted to simply go ahead and use data is equals to report json like this. But this expression here will result into an error. As we have decorated our function with pytest fixture, pytest fixture does not allow you to call the function directly to get the data. Instead, you have to request for the same. So how do we get the fixture, I mean our data inside of our test function? Well, to do that, you can simply request for it. That is, when you define our test function, inside of the arguments, you can write something light report json now pytest when it will go ahead and run our test function it will find this report json argument then it will go ahead and find a fixture that matches the name and it finds our report json fixture then it goes ahead and runs the same and provides the return value as an argument to our test function…

Contents