Hi Prashashti, to create a fixture that will be shared across several tests, you have to put it in the file conftest.py. Any fixture in it will be recognized automatically. A fixture that starts the web browser looks like this:
@pytest.fixture(scope="session")
def driver_get(request):
from selenium import webdriver
web_driver = webdriver.Chrome()
session = request.node
for item in session.items:
cls = item.getparent(pytest.Class)
setattr(cls.obj,"driver",web_driver)
yield
web_driver.close()
@pytest.fixture above driver_get() function indicates that this function will be used as a fixture with scope=session. The request parameter refers to the test session, as fixture functions can accept the request object to introspect the “requesting” test function, class, module or session, depending on the scope.