If your web or mobile 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 in the application to finish logging in.
Setup
Before training a login flow that uses email OTP, make sure you set up the following:
- Create a permanent mabl Mailbox address.
- Register a new user account in your application using the permanent email address
- Create mabl credentials using the permanent email address and password for the new account.
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 test is associated with the MFA credentials you just created:
Associating a test with credentials
Train the email OTP login
In the mabl Trainer, log into the application using the mabl credentials: app.defaults.username and app.defaults.password. When the application under test prompts you to check your email for a one-time code, open mabl Mailbox.
In the Select inbox dropdown, select and open the permanent inbox associated with the email address.
Confirm the email match criteria to open the email. Extract the element that contains the email verification code and store it in a variable: {x} > Create a variable > Element property.
If the verification code is part of a larger text block, such as “Your verification code is 483291”, store the full text in a variable and a subsequent step to parse the variable with JavaScript: {x} > Create a variable > JavaScript. To see an example of how this works, see the article on data manipulation with JavaScript snippets.
Extracting the verification code
After creating the verification code variable, return to your app and complete the login.