OTP (sms) login?

does anyone know how to automate OTP (sms) login?

2 Likes

@istle_z If you really donโ€™t have the option to have a proper test environment with an option to turn it off, then SMS Gateway API would be a way to go.

SMS Gateway API allows you to send and receive SMS messages using API calls by interacting with the SMS gateway of a service provider. You can use these APIs for testing within your test code to ensure that your SMS functionality works as expected.

1 Like

Thanks, Iโ€™ll give it a go

1 Like

Itโ€™s hard to suggest a specific one without knowing the project and automation requirements but ping me if you need any help. Maybe Iโ€™ll be able to give a hint or something :slight_smile:

@istle_z can you tell us more about what you are doing? Give more background and context?

1 Like

I believe by far the easiest way is to use testRigor. Hereโ€™s the video: Tips & Tricks - Two Factor Authentication & SMS Testing - testRigor AI-Based Automated Testing Tool disclaimer: Iโ€™m a co-founder of testRigor

2 Likes

I have found Twilio to be good enough for this.

2 Likes

Thanks, Iโ€™ll give it a trial.

Thank you, Artem, itโ€™s my pleasure. Iโ€™ll give testRigor a trial.

1 Like

Twilio or a testing service like Mailinator are great. You can get an SMS phone number (supplied by Twilio) and Mailinator provides an API to get whatever data / messages are sent to it.

1 Like

Two ways:

  1. Use a service like MITM proxy to intercept the API call and grab the code from the call. This test would be fast and hermetic.
  2. Use a service like twilio.

I sometimes set up end to end tests that can run with both modes. I run 1 in CI very frequently. 2 I run much less frequently - itโ€™s slower, costs money, etc. but is helpful if/when the OTP code changes and can detect bugs caused by the API changing.