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.

I’ve used both methods you mentioned before. The MITM proxy method is definitely quicker and more controlled, but I agree with you that using Twilio is slower and costs money. It’s been useful when I need to test for changes in the OTP or API, but I try to avoid it for routine tests because of the cost.

A while ago, I was working on a project where I needed a temporary phone number for OTP verification. I didn’t want to use my personal number, so I tried Tardigrada. It was super handy, and I didn’t have to deal with the costs or setup like Twilio. It worked perfectly for testing and got me through without any issues.