How to capture otp from android mobile during registration/login in a app
Check out this post and video for a walkthrough on how to capture One Time Password (OTP):
@Chris_Trevarthen Could you please help me with the same OTP reading when I try to sign in using android mobile app ?
I haven’t worked with OTP testing, but if you are able to share screenshots or videos of the process, I might be able to help figure out how to inspect some elements.
As soon as I enter my login credentials, the OTP will get displayed as a notification. It will also be in my ‘Text Messages’ folder.
I need to read this otp from either notification or sms folder and enter it to login my application. There are several ways to do it for a web application but for a mobile app there are no procedures.
Please help me.
Refer attached images.
Thanks for the screenshot, that helps me understand a bit better what you’re trying to do. I don’t think you’ll be able to access the notification popup message with Katalon Studio/Appium, but I think you might be able to switch to the Notifications application and read the latest notification to get the OTP code.
- Use Katalon Studio to Spy Mobile using an apk file that you have on your machine
- Trigger the OTP notification on your emulator or device
- In the emulator or device, switch to the Android Notifications app
- Capture the object for the corresponding notification message in the Notifications app - this is probably the latest one - name this something like “First Notification Item”
- Capture the text object for the notification that contains the OTP - name this something like “OTP Text”
- Save the text object in the Test Object repository
- Stop the spying process
- Open your test case
- Switch to the “Script” view of the test case
- After the spot in your test case that you trigger the OTP request and the notification appears, add a line for:
This should open the Android Notifications app programmatically
- Add code to tap the latest notification object, which should be something like:
Where “First Notification Item” is what you named the captured first notification element when you were spying
TestObject notification = findTestObject('Object Repository/First Notification Item') Mobile.tap(notification, 10)
- Add code to get the text of the OTP:
TestObject otp = findTextObject('Object Repository/OTP Text') String otpText = Mobile.getText(otp, 10)
- You can then switch back to the main app using
- Use the OTP text you captured above and set it in to the password field in your app using
It’s a bit of a round-about process, but I think the concept should work for what you want to do.
Hope this helps,