Skip to content
Advertisement

Getting fixture not found in pytest

I am getting following error while running pytest using following code im unable to figure out whats wrong please find below code snippets.

Console ouput :

JavaScript

My Base class contains following code:

JavaScript

and test class contains following code:

JavaScript

The test fixture is web_driver still getting error not found !

Advertisement

Answer

web_driver() is defined outside Base class scope, so it’s invisible to the usefixtures as it is part of test class scope. You could move it to conftest file, but IMHO a better solution is to move web_driver inside Base

JavaScript

As a side note, it should be driver.close(), not web_driver.close()

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement