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
Click Continue to start the login process
Choose Receive code by email to request the OTP
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.
In the OTP field of your flow, replace the hard-coded value with your new variable (`otp`). Click Update.
Run your test case.
- ContextQA will automatically:
- Open the URL
- Enter your email address
- Click Continue
- Click Receive code by email
- Wait for your OTP
- Extract the live OTP
- Enter the OTP into the field
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.
Last updated