I am new to python. I have requirement that login must be done before running the all the test. i.e. on class level. if i have two test file TEST_F1 , TEST_F2 then when i run the test the login page popup and after successful login it must run all the test in TEST_F1 . When it start to run TEST_F2 then login page must popup again to validate. I am using python , Pytest ,slenumnbase lib
I was not able to archive this in python. It works for me in C# selenium.
You can create a fixture to handle the login logic and use it in your test classes.
Here's an example:
Create a fixture for login in conftest.py:
Use the login fixture in your test classes: