This guide shows how to run an OTP test for SMS-based MFA using Playwright.
Quick answer: what is an OTP test?
An OTP test validates that one-time passcodes are sent, received, parsed, and accepted correctly during sign-up or login workflows.
Why automate OTP tests?
- Authentication is a release-critical path
- Manual OTP testing is slow and inconsistent
- Real phone number flows expose production-like failure modes
Test flow overview
- Create a test phone number
- Open application sign-up page with Playwright
- Submit registration form
- Wait for inbound SMS OTP code
- Enter code and confirm successful login
In this guide we use a demo SMS auth app at playground-sms.mailslurp.com.
Playwright setup
Create project
Install Playwright
Implement OTP test with Playwright
Load sign-up page
Fetch a test phone number
Fill and submit registration form
Wait for SMS and extract OTP
Submit OTP and verify account access
Cross-framework note
The same OTP test pattern works in Cypress and Selenium:
- Create controlled number
- Trigger auth flow
- Wait for code
- Assert confirmation success
See email and SMS testing guides for related workflows.
Related pages
SMS OTP release checklist
Before shipping authentication changes, verify this sequence:
- Exercise auth sign-up and login paths in Email Sandbox.
- Run regression suites in CI with Email Integration Testing.
- Capture OTP delivery and verification events through Email Webhooks.
- Apply fraud-response and retry logic with Email Automation Routing.
- Confirm delivery timing reliability with an Email Deliverability Test.
Final take
A reliable OTP test should run in CI for every release candidate. When auth flows break, users cannot onboard or sign in, so this is one of the highest ROI test suites to automate.



