Suppose, I have login to application function in setup module with the scope session.
Test file name: test_login_app.py
@pytest.fixture(scope="session")
def setup_module(request):
login_to_app(username, password)
#above function is responsible for login with multi-factor authentication using otp(google authenticator) into the application.
def teardown_module():
logger.info('Tearing Down Test Module.')
driver.quit()
driver.close()
request.addfinalizer(teardown_module)
@pytest.mark.regression
def test_login_to_application(setup_module, service_data):
#service_data is a parametrize fixture which is responsible to get the service data from test data file.it is data driven framework.
// performing some actions
// performing assertion.
Now the issue is, I need to execute this test file in parallel mode but when I'm running it in parallel mode with more than 1 node then it is launching the browser and loading the url also but to login to the application it requires otp, so on 1st node it is taking the otp 1st and then same otp is going into the other nodes for login so in that case, message we are getting after inputting the same otp is that its already used so we are regenrating the otp also and login to the 2nd node but when it comes to 3rd or 4th node then at that time, there would be an error to enter the otp like there are too many otp entered.
So how can I handle this otp issue in parallel mode with pytest framerwork? or any other approach if you can suggest. ??
Thanks in advance.