Logging in with an email verification code

If your application uses email one-time password (OTP) authentication, you can automate your login flow using mabl Mailbox and mabl credentials.


What is email OTP?

In an application that uses email one-time password (OTP), the user enters their username and password and requests a verification code. The application sends a verification code to the user's registered email address, and the user enters that verification on the application to finish logging in.


Before training a login flow that uses email OTP, take the following steps:

  1. Create a permanent mabl Mailbox address.
  2. Register a new user account in your application using the permanent email address
  3. Create mabl credentials using the permanent email address and password for the new account.
Creating mabl credentials

Creating mabl credentials

Launch the Trainer

After creating MFA credentials, you're ready to train a login that uses email OTP in the mabl Trainer! Make sure the browser test is associated with the MFA credentials you just created:

Associating a test with credentials

Associating a test with credentials

Train the email OTP login

In the mabl Trainer, take the following steps to train a login that requires email OTP:

  1. Log into the application using the mabl credentials: app.defaults.username and app.defaults.password.
  2. When the application under test prompts you to check your email for a one-time code, open mabl Mailbox.
  3. In the "Select inbox" dropdown, select the permanent inbox associated with the email address.
  4. Click on the Open button.
Open verification code

Open verification code

  1. Confirm the email match criteria.
  2. When the browser window shows the email with the verification code, create a new variable: {x} > Create a variable.
  3. Set the variable source to "Element property"
  4. Click on the element that contains the verification code in the email.
Extracting the verification code

Extracting the verification code

  1. Give the variable a name, such as verification_code, and save.
  2. Enter the verification_code variable in the application.
  3. Complete the login.