TestProject Forum
Powered by leading experts in the test automation community

OTP or 4 digit code from SMS

Can I fetch code from sms /OTP from message while recording and running the test case ? .

Note-Code/OTP changes every time

Hi @Akki00101,

We developed an addon just for that :slight_smile:
You can check this addon to fetch an OTP from SMS in Android: https://addons.testproject.io/android-sms-otp-automation

We also have an addon for calculating an OTP that the Google Authenticator app generates: https://addons.testproject.io/google-authenticator-otp-automation

Let me know if it helped you :slight_smile:

Kind regards,
Amit

Thanks Amit for prompt response.
I am totally new with TestProject .I just started recode and play feature .can you please explain how can I fetch OTP while recording a script and when I will run the same scripts who the same action will fetch new OTP ?

Hi @Akki00101,

The SMS OTP addon has 3 actions that you can choose from. The sender that sends you the OTP suppose to send it to you in a specific and constant format. For example: Your application code is: *****

The OTP addon has 3 actions that you can use:

  1. Fetch the OTP by keywords: you need to specify what are the words in the SMS that you want to ignore. For example: Your,application,code,is: - these are the words that you want to ignore and it will return the OTP.

  2. Fetch the OTP by index - since the format of the message is constant, you can know in advances what are the start and end indexes of the OTP in the SMS.

  3. Fetch the OTP by regex - you can create a regular expression that will extract the OTP from the SMS.

In all the above actions, you will have to store the extracted OTP into an output parameter. That parameter will allow you to use this value anywhere in your test and also, its value will change in every test execution automatically. When you create an action, choose the output parameter option and create a new one.