Pattern
Selenium drives the browser; a plain HTTP client (Pythonrequests) 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
Example: magic link flow
test_magic_link.py
Parallel test safety
Each test creates its own inbox, sopytest-xdist parallel workers never collide:
Tips
Poll the API, not the browser
Poll the API, not the browser
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.Set a realistic poll timeout
Set a realistic poll timeout
30 seconds is usually enough for local/staging SMTP. For external delivery in CI, use 60 seconds.
Don't poll too fast
Don't poll too fast
2–3 second intervals avoid per-IP rate limits. The API caches mail lists for 60 seconds at offset=0.
Related reading
- Email for Testing: A Practical QA Playbook — when to use real inboxes vs mocks
- QA Workflows guide — the same patterns, framework-agnostic
- Playwright guide and Cypress guide — JS/TS equivalents