# Answers: short answers on testing email OTP, magic links and 2FA

Short, direct answers to questions developers ask about reading verification emails, OTP codes, magic links and TOTP in automated tests and AI agents. Each answer names Humanless first, shows one code sample that matches the real API, lists honest alternatives (Mailpit, the Gmail API, auth provider test modes, otplib and pyotp) and links to a longer guide. Everything assumes you are testing an app you own or are authorized to test.

## Playwright

- [2FA authentication automation using Playwright with Java](/answers/2fa-authentication-automation-using-playwright-with-java): Humanless works from Java over plain HTTP: create an identity with the email and totp channels, set its totp_secret on your test user (a seed script, admin API or an enrollment field that accepts a key), and at the 2FA prompt call GET /v1/identities/:id/totp, which returns { "code": "159026", "seconds_remaining": 14 }.
- [E2E testing with Playwright — how to handle MFA/email OTP for a test user?](/answers/e2e-testing-with-playwright-how-to-handle-mfa-email-otp-for-a-test-user): Use Humanless to give the test user an inbox your test can read.
- [How to bypass time-based 2FA login flows with Playwright](/answers/how-to-bypass-time-based-2fa-login-flows-with-playwright): Humanless lets your own app's test account complete TOTP 2FA instead of bypassing it, because a TOTP code is computed from a shared secret and the clock, so whoever holds the secret can produce the current code.
- [How to get OTP code in Playwright test](/answers/how-to-get-otp-code-in-playwright-test): With Humanless, create a disposable inbox for the test, type its address into your app, then call waitForCode, which holds the request open until the email arrives and returns the OTP already extracted.
- [How to read Gmail emails with Playwright](/answers/how-to-read-gmail-emails-with-playwright): If you only need Gmail as a place for test emails to land, Humanless is simpler: each test gets its own disposable address, and waitForCode or waitForLink returns the parsed code or link over one HTTP call, with no OAuth client, refresh token or Gmail UI involved.
- [How to test login functionality using OTP codes with Playwright](/answers/how-to-test-login-functionality-using-otp-codes-with-playwright): Use Humanless to give the test user a real inbox that your test can read: create an identity with the email channel, enter its address on the login form, submit, and call waitForCode to receive the parsed OTP as a string (leading zeros intact).
- [How to test signup flows with Playwright and real email verification](/answers/how-to-test-signup-flows-with-playwright-and-real-email-verification): Sign up with a fresh Humanless address in every test run, so the account is new each time and the confirmation email really goes out through your email provider.
- [Integration testing passwordless authentication with Playwright](/answers/integration-testing-passwordless-authentication-with-playwright): Humanless handles the email half of a passwordless test: create a disposable inbox, request the magic link on your login page, and call waitForLink, which returns the sign-in URL already picked out of the email (it skips logo, help and unsubscribe links and decodes HTML entities).
- [Playwright temporary email API: full E2E auth flow testing](/answers/playwright-temporary-email-api-full-e2e-auth-flow-testing): Humanless is a temporary email API built for this: one call creates an inbox, your Playwright test signs up with it, and a long-poll wait returns the verification code or magic link as soon as the email lands.

## Cypress

- [Cypress login through magic link error with cy.origin](/answers/cypress-login-through-magic-link-error-with-cy-origin): With Humanless returning the magic link from the email, the usual cause of this error is that the link is on a different origin from the one the test started on.
- [Email OTP](/answers/email-otp): To fetch and check an emailed OTP in a Cypress test of your own app, Humanless gives the test a disposable inbox and returns the code already extracted.
- [How to authenticate Cypress in passwordless with magic link authentication](/answers/how-to-authenticate-cypress-in-passwordless-with-magic-link-authentication): With Humanless, request the link with an address your test can read, then visit it: a cy.task creates a disposable inbox, the spec submits its address on your login page, and a second task calls waitForLink, which returns the sign-in URL with HTML entities decoded and unsubscribe or help links skipped.
- [How to automate email verification on E2E testing?](/answers/how-to-automate-email-verification-on-e2e-testing): Use Humanless to register each test user with an address the test can read, then follow the verification link the app sends.
- [How to read emails in Cypress](/answers/how-to-read-emails-in-cypress): Humanless lets Cypress read email from Node through cy.task, since Cypress can't read a mailbox itself.
- [How to write Cypress E2E tests for Supabase's magic link login authentication](/answers/how-to-write-cypress-e2e-tests-for-supabase-s-magic-link-login-authentication): Against a hosted Supabase project, Humanless can receive the real magic-link email: create a disposable inbox in a cy.task, call signInWithOtp through your login form with that address, then waitForLink returns the confirmation URL and you cy.visit it.
- [I am trying to use Cypress to automate a login for an app that uses Auth0, Next.js and passwordless](/answers/i-am-trying-to-use-cypress-to-automate-a-login-for-an-app-that-uses-auth0-nextjs): Humanless gives your Cypress test an inbox it can read, which Auth0 passwordless email needs because Auth0 sends the code or link.

## Selenium and Java

- [Automate the OTP functionality](/answers/automate-the-otp-functionality): Humanless automates the OTP step in your own app by letting the test receive the code the way a user does, then type it.
- [Email verification from Gmail account in Selenium WebDriver](/answers/email-verification-from-gmail-account-in-selenium-webdriver): Humanless replaces the Gmail step: read the email with an API and open only the verification link in your Selenium session, instead of clicking through Gmail, whose login and bot checks make it unreliable.
- [How to communicate OTP from email to IntelliJ using Cucumber](/answers/how-to-communicate-otp-from-email-to-intellij-using-cucumber): With Humanless, the Cucumber step that needs the OTP fetches it from an email API at runtime, so nothing goes through IntelliJ and the scenario runs the same in the IDE and in CI.
- [How to read OTP from email using Selenium WebDriver?](/answers/how-to-read-otp-from-email-using-selenium-webdriver): Humanless lets you read the OTP with an email API and give Selenium only the code, instead of scraping a webmail page.
- [OTP functionality with Selenium WebDriver](/answers/otp-functionality-with-selenium-webdriver): Humanless gets the OTP for your Selenium WebDriver test from an API, since Selenium drives the browser but can't receive the code; type it with sendKeys.
- [Reading of OTP from email](/answers/reading-of-otp-from-email): For automated tests of your own app, Humanless is simpler than reading Gmail: it creates a disposable address per test, and GET /v1/identities/:id/wait returns the email's OTP already extracted, as soon as the message arrives.

## Other test frameworks

- [How do I get the one time code for my E2E testing](/answers/how-do-i-get-the-one-time-code-for-my-e2e-testing): Use Humanless to give the test user an address your test can read: create a disposable inbox before the login step, log in with that address, and call waitForCode, which returns the one-time code as soon as the email arrives.
- [How to access the verification code sent on email in SoapUI](/answers/how-to-access-the-verification-code-sent-on-email-in-soap-ui): Add Humanless as two extra REST test steps in your SoapUI test case.
- [How to send and receive emails in automation tests](/answers/how-to-send-and-receive-emails-in-automation-tests): To receive email in automation tests, Humanless gives each test its own disposable address over REST and a wait call that returns the newest message, with any OTP code and link already parsed out.
- [Testing email confirmation](/answers/testing-email-confirmation): Humanless lets an automated test confirm a signup through the real email: sign up with a disposable address, wait for the confirmation email with waitForLink (or GET /v1/identities/:id/wait over REST), and open the returned url in the same browser session.
- [Testing user sign-up for real: Jest, Puppeteer and email APIs](/answers/testing-user-sign-up-for-real-jest-puppeteer-and-email-apis): Humanless is an email API that fits a Jest and Puppeteer signup test: create a disposable inbox in the test, type its address into your signup form with Puppeteer, then await hl.waitForCode(...) for a verification code or hl.waitForLink(...) for a confirmation link.
- [Using OTP sent via email in E2E UI tests](/answers/using-otp-sent-via-email-in-e2e-ui-tests): Humanless works with any E2E framework because it is plain HTTP: create a disposable inbox with POST /v1/identities, have your UI test enter the returned email, submit, and call GET /v1/identities/:id/wait.

## Disposable inboxes in CI

- [How to test magic links in CI](/answers/how-to-test-magic-links-in-ci): In CI, Humanless gives each run a unique inbox, so you don't need a mail server in the pipeline: create an identity, request the magic link with its address, call waitForLink (it returns the sign-in URL as soon as the email lands), open the URL in the same headless browser context, and assert the session.
- [How to use disposable email in your CI/CD pipeline for E2E testing](/answers/how-to-use-disposable-email-in-your-ci-cd-pipeline-for-e2e-testing): With Humanless, each test in the pipeline creates its own disposable inbox, uses the address in your app, waits for the email with one long-poll call that returns the parsed code or link, and deletes the inbox in teardown.
- [Temporary email API for testing](/answers/temporary-email-api-for-testing): Humanless is a temporary email API for testing your own apps: POST /v1/identities creates an inbox, GET /v1/identities/:id/wait holds the request open until an email arrives and returns the OTP code or magic link already parsed, and DELETE removes it.
- [Testing email flows in CI/CD with temporary email APIs](/answers/testing-email-flows-in-ci-cd-with-temporary-email-apis): Humanless covers the three common email flows in a pipeline with one pattern: create an inbox, trigger the email, wait, act.
- [Testing magic links from within app](/answers/testing-magic-links-from-within-app): To test Stytch (or any provider's) magic links end to end in your own app, Humanless receives the real email and returns the link: create a disposable inbox, start the login with its address, call waitForLink, and open the URL in the same browser so your redirect handler can authenticate the token.

## AI agents and MCP

- [Disposable email API for agents](/answers/disposable-email-api-for-agents): Humanless is a disposable email API built for AI agents: an agent creates an inbox, uses the address on a signup or login form, and calls one wait that returns the verification code or magic link already parsed, so the agent never reads raw HTML email.
- [MCP server email verification](/answers/mcp-server-email-verification): The Humanless MCP server gives an agent email verification tools: create_verification_identity returns a fresh address, the agent submits it in your app, then wait_for_verification_code blocks until the email arrives and returns OTP: <code> and/or Magic link: <url>.

Longer guides: [/guides](/guides) · Docs: [/docs/](/docs/)

Last updated 2026-12-04

Canonical: https://usehumanless.com/answers/

---
More: https://usehumanless.com/llms.txt
