I have a scenario where I need to perform a login, but the problem is its based on OPT (I mean once I enter a phone number to that number I receive an OTP That OTP is the password)
-
Generally the problem is knowing what the OTP is. Which means from a testing standpoint you have to be able to fetch the password prior to use.Marcel Wilson– Marcel Wilson2018年11月21日 16:11:24 +00:00Commented Nov 21, 2018 at 16:11
1 Answer 1
In software testing companies generally we are automating it by storing OTP in Database and then it is easy to automate by us while devops testing. You can use sql connection and get the 'OTP' code.
Please find below code snippet in support of above suggestion. I hope this approach will work well for you.
import pyodbc
cnxn = pyodbc.connect("Driver={SQL Server Native Client 11.0};"
"Server=server_name;"
"Database=db_name;"
"Trusted_Connection=yes;")
cursor = cnxn.cursor()
cursor.execute('SELECT otp FROM Table')
for row in cursor:
print('row = %r' % (row,))
Thanks.