How can I test when app requires OTP via SMS?



  • I am using Selenium with Java to test a web application. The app requires a user to receive a One-Time Passcode (OTP) to authenticate they are who they say they are and to authorize several critical transactions.

    I have the automation code for the web application itself, but I need something methodology for the OTP, which is sent via SMS/text to a mobile device.

    I know I need some API/Web service that will emulate a phone, allow me to query it and return the message sent to it.

    I have looked at Twilio and a few other such services, but they require you to start the process with them. Such as by sending an SMS to request an OTP, and then they will send back an OTP back for you to consume. But the app has its own OTP generator, so Twilio and such will not work for me.

    Anyone have any suggestions or examples I can borrow?

    Thank you.



  • Another option you could try is Google Voice (voice.google.com). This will give you a web interface to a phone number which is free for your first number.

    I have used the app to test two factor authentication, so it should work for at least manual testing of your scenario.

    Google allows you to have one number without charge, but you need to pay for any extra numbers.



Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2