Skip to main content

Pattern

Selenium drives the browser; a plain HTTP client (Python requests) talks to the TempInbox API from the test process. No Selenium-specific integration is needed — the API is plain REST.

Helper: tempmail.py

tempmail.py
POST /api/new_address is protected by Cloudflare Turnstile on the public instance. For automation, pre-create addresses in the web UI and reuse the JWT, or run against a self-hosted instance with Turnstile disabled. See API Overview for the recommended JWT workflow.

Example: OTP signup test (pytest)

test_signup.py

test_magic_link.py

Parallel test safety

Each test creates its own inbox, so pytest-xdist parallel workers never collide:

Tips

Never use Selenium to open the TempInbox UI and scrape the inbox — poll GET /api/mails from Python instead. It is faster, has no UI-flake surface, and does not consume a browser session.
30 seconds is usually enough for local/staging SMTP. For external delivery in CI, use 60 seconds.
2–3 second intervals avoid per-IP rate limits. The API caches mail lists for 60 seconds at offset=0.