Email Validation

Many web applications ask for a one-time password (OTP) when you log in. Automating these flows is tricky because OTPs are dynamic—they change every login and expire quickly. With ContextQA, you can automate this process reliably.

Let’s walk through automating a login that requires a 2FA OTP, showing you how to extract the live code from your email and use it in your test.


Launch the login page and enter your email address

Image

Click Continue to start the login process

Image

Choose Receive code by email to request the OTP

Image

Try to log in—notice access is denied without the OTP.

Automate the login steps in ContextQA’s recorder.

  • Enter your email address.

    Image
  • Click Continue with email.

    Image
  • Enter an OTP (use any static code at first).

    Image
  • Attempt verification.

    Image

Step 6: Replace the static OTP with dynamic extraction.

  • After submitting the email, click Add step to insert a Wait (e.g., 10 seconds) so your OTP can arrive.

    Image
  • Add a step to extract the OTP from your email: - Click the three dots.

    Image

    - Paste your email address. - Use a regular expression to match a 4-digit OTP (e.g., `[0-9]{4}`). - Name the variable something like `otp` or use a prompt like "Fetch the otp". Both regex and AI prompts are supported.

Click Create to save your extraction step.

Image

In the OTP field of your flow, replace the hard-coded value with your new variable (`otp`). Click Update.

Image

Run your test case.

- ContextQA will automatically:

- Open the URL

Image

- Enter your email address

Image

- Click Continue

Image

- Click Receive code by email

Image

- Wait for your OTP

- Extract the live OTP

- Enter the OTP into the field

Image

Your login is now automated—even with dynamic, single-use OTP codes. No more failed tests from expired values!

ContextQA’s OTP extraction keeps your 2FA flows secure, reliable, and effortless.

Supporting Videoarrow-up-right

Last updated