After giving a mobile number on the website to login it asks for otp..Have to read OTP from DB.how can I automate the process to read the OTP from DB to login.
Asked
Active
Viewed 2,229 times
-2
-
`select otp_code from otp_table where number =@number` and pass it to Selenium? There's not enough detail to answer your question beyond that – Martheen Jul 28 '20 at 06:00
-
@Martheen thanks for the response. am automating a login process of a website in UAT environment, in selenium with python... when I login using a mobile number -> it will send OTP to login -> I have to read that OTP from DB to go further. hope this detail helps.. – K Chaithanya Jul 28 '20 at 07:42
-
That's exactly what you're saying in your question. Read https://stackoverflow.com/help/how-to-ask and edit your question – Martheen Jul 28 '20 at 07:45
1 Answers
0
Hi This is worst practice in selenium automation
Two Factor Authentication shortly know as 2FA is a authorization mechanism where One Time Password(OTP) is generated using “Authenticator” mobile apps such as “Google Authenticator”, “Microsoft Authenticator” etc., or by SMS, e-mail to authenticate. Automating this seamlessly and consistently is a big challenge in Selenium. There are some ways to automate this process. But that will be another layer on top of our Selenium tests and not secured as well. So, you can avoid automating 2FA.
There are few options to get around 2FA checks:
- Disable 2FA for certain Users in the test environment, so that you can use those user credentials in the automation.
- Disable 2FA in your test environment.
- Disable 2FA if you login from certain IPs. That way we can configure our test machine IPs to avoid this.

Justin Lambert
- 940
- 1
- 7
- 13