CARRIER TRUNKS: 24 ACTIVE | GATEWAY: D1 EDGE REPLICATED | SYSTEM STATUS: OPERATIONAL
MODEL CONTEXT PROTOCOL (MCP) READY

Playwright OTP Login Automation

Complete guide and executable Python script for automating SMS two-factor authentication testing in Playwright without flaky carrier delays.

test_otp_login.py
Automation / Playwright
import pytest
from playwright.sync_api import Page, expect
import requests

def test_otp_login(page: Page):
    page.goto("https://app.example.com/login")
    page.fill("#email", "tester@example.com")
    page.click("button[type=submit]")
    
    # Trigger synthetic OTP code
    res = requests.post("https://smsriver.com/api/v1/synthetic/sms/", headers={"Authorization": "Bearer sk_test"}, json={"to": "+12025550101", "body": "Your code is 123456"})
    
    page.fill("#otp", "123456")
    page.click("#verify-btn")
    expect(page.locator(".dashboard-header")).to_be_visible()
requirements.txt
REST API v1
playwright>=1.49.0
pytest>=8.0.0
requests>=2.31.0

Implementation Walkthrough

1

Initialize Browser Context

Launch headless Chromium using Playwright and navigate to your authentication page.

2

Inject Deterministic Synthetic Code

Use the SMSRiver API to deliver a predictable test passcode to the assigned virtual inbox.

3

Assert State Transition

Verify that user enters dashboard state and authentication tokens are properly issued.

Supported MCP Agent Tools

list_countries
alias: sms_list_numbers

Discover supported countries, inventory counts, and carrier capabilities by source type.

get_number_capabilities
alias: sms_get_capabilities

Check line types, SMS capabilities, carrier limitations, and rental costs for a phone number or ISO country.

create_test_inbox
alias: sms_create_inbox

Create an isolated synthetic test inbox for deterministic webhook integration testing without real carriers.

generate_test_sms
aliases: sms_generate_sms, sms_create_synthetic_message

Inject zero-carrier-cost synthetic SMS inbound events directly into webhook endpoints for CI/CD test automation.

simulate_delivery_failure
alias: sms_simulate_failure

Simulate carrier drops, 10DLC rejections, DND blocks, and queue timeouts to verify retry handling.

inspect_webhook_events
alias: sms_inspect_webhooks

Query recorded test events, delivery status, latency, and raw carrier webhook payloads within plan retention.

replay_test_event
alias: sms_replay_event

Replay an existing test event to re-trigger local webhooks or reproduce failed integration test cases.

get_usage_summary
alias: sms_get_usage

Inspect current billing plan, monthly quota, consumed requests, and remaining units across REST and MCP.

Copied to clipboard