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 credential profile: 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, enter it in the Test OTP / PIN field of the project's credential profile, along with the Phone Number if your login asks for one. TestOptim uses the code automatically and exploration never pauses.

A TestOptim credential profile with Username, Password, API Key, Login URL, Phone Number and Test OTP / PIN fields
The Phone Number and Test OTP / PIN fields on a credential profile.

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 the profile has a Test OTP / PIN.

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

Leave Test OTP / PIN blank 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 credential profile per role, and you choose which profile each exploration signs in as. See Add login credentials.

Frequently asked questions

Can TestOptim AI test an app with OTP login?

Yes. Give the credential profile a fixed Test OTP / PIN that your test environment accepts, or leave it blank 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 Test OTP / PIN in TestOptim?

It is a field on a credential profile for a static code your app accepts for testing, such as 123456. 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 the credential profile has a Phone Number field for apps that sign in with 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 Test OTP / PIN on the profile. 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.

GET STARTED FREE

Point TestOptim AI at your app

3-day free trial · No SDK, no test code · Cancel anytime