Skip to content

OTP and two-factor login

Test OTP login flows and pages behind two-factor sign-in

Short answer

TestOptim AI can test apps behind an OTP login. Give it a fixed test code and it signs in by itself. Leave the code blank and exploration pauses at the code screen, emails you a link, and waits while you request the live SMS or email code and type it in. Then exploration carries on.

Why OTP logins break most test automation

A one-time password sent by SMS or email is designed so that only a person holding the phone or inbox can sign in. That is exactly what stops an automated test: the agent reaches the code screen, has no way to read your messages, and every page behind the login stays untested.

TestOptim AI handles OTP login in two ways, and you pick per test login: a fixed test code your staging app accepts, or a short pause where a person on your team supplies the live code.

Option 1: give TestOptim a fixed test OTP

If your test or staging environment can accept a fixed code, such as 123456 for test accounts, pick Phone & code on the project's test login, choose Yes, it's always the same and enter the code. TestOptim uses the code automatically and exploration never pauses.

A TestOptim test login on the Phone & code tab with a phone number and the fixed code 123456
A test login that signs in with a phone number and a fixed code.

This is the option to choose if you want test runs to get past the login too. Only exploration can wait for a live code. Test runs and fix checks can't, so they can't sign in to a login that sends a code unless it has a fixed code.

Option 2: exploration pauses and emails you for the live code

Choose No, it's different every time and exploration still gets through a real OTP login. When the agent reaches the code step, it pauses and hands the moment over to a person:

  1. 1Exploration pauses. The live log shows "Waiting for you to request a verification code". Nothing has been sent to your phone or inbox yet, so the code can't expire before you are ready.
  2. 2You get an email. The person who started the exploration (or the project owner, if that isn't known) gets "Action needed: <project> needs a verification code" with an Open OTP Page button.
  3. 3You request the code. On the Verification code page, click Send my code. TestOptim asks your app to send the code now.
  4. 4You type it in. Enter the code you received before the countdown ends and click Submit code. Exploration resumes.

The Owner, Admins, QA Leads and QA Engineers can request and submit the code; Developers and Viewers can't. If the email went to someone who isn't allowed to, they can forward the link to someone who is.

Time limits for the one-time code

How long you have at each step
StepHow long you have
Open the page and click Send my codeUp to 30 minutes after the pause
Type the code after it is sent5 minutes, shown as a countdown

If time runs out, the agent carries on with whatever it can reach without logging in, and nothing it already found is lost. Waiting for you doesn't count toward the exploration's own 45 minutes of exploring.

Use a test account, not a real one

The agent signs in and works through your app like a QA engineer. It never logs out, deletes accounts, makes payments, or changes passwords or account settings, but it does fill in and submit forms. Give it a dedicated test account on staging with the access a normal user of that role has, and never a production admin login.

Passwords, API keys and codes are encrypted when saved and never shown again. Apps with several roles get one test login per role, and you choose which login each exploration signs in as. See Add login credentials.

Frequently asked questions

Can TestOptim AI test an app with OTP login?

Yes. Give the test login a fixed code that your test environment accepts, or tell TestOptim the code is different every time and exploration pauses and emails you so you can enter the live code.

Can TestOptim read the code from my phone or inbox?

No. The agent can't read your phone or inbox. That is why exploration pauses and asks a person on your team to request and enter the code.

What is a fixed test code in TestOptim?

It is a code your app always accepts for testing, such as 123456, saved on a Phone & code test login. When it is set, TestOptim uses it automatically and exploration never pauses.

Does TestOptim support SMS one-time codes as well as email codes?

Yes. The pause-and-email handover works for codes sent by SMS or email, and a test login can sign in with a phone number and an SMS code.

Who gets the email when exploration needs a code?

The person who started the exploration, or the project owner if that isn't known. The email's subject is "Action needed: <project name> needs a verification code".

Who can enter the one-time code?

The Owner, Admins, QA Leads and QA Engineers. Developers and Viewers can't request or submit it, so forward the link to someone who can.

How long do I have to enter the code?

Up to 30 minutes after the pause to click Send my code, then 5 minutes to type the code once it has been sent. The page shows a countdown.

Why doesn't TestOptim send the code as soon as it pauses?

So the code doesn't expire before you're ready. Nothing is sent until you click Send my code, so have your phone or inbox in front of you first.

What happens if I miss the OTP deadline?

The agent carries on with whatever it can reach without logging in. Nothing it already found is lost, and you can start a new exploration later.

Does waiting for the code use up exploration time?

No. The time the run waits for your code doesn't count toward the exploration's 45 minutes of exploring.

Can test runs get past an OTP login?

Only with a fixed code on the test login. Test runs and fix checks can't wait for a live code, so a login that sends a code needs a fixed test code for them.

Are OTP codes and passwords stored securely?

Passwords, API keys and codes are encrypted when they're saved, and the screen never shows them again after you save.

START YOUR 7-DAY TRIAL

Point TestOptim AI at your app

7-day trial, card required · No SDK, no test code · Cancel anytime