Testing guide
Test email flows with Selenium without opening Gmail
Selenium recommends using an email provider API instead of automating Gmail or another mailbox interface. PNTR separates those jobs: WebDriver exercises your application, while a small API poll retrieves the message.
Explore PNTR's disposable email for developersPython inbox helper
import os, time, requests
def wait_for_email(recipient):
url = f"https://api.pntr.dev/api/subdomains/{os.environ['PNTR_SUBDOMAIN_ID']}/emails"
headers = {"Authorization": f"Bearer {os.environ['PNTR_TOKEN']}"}
for _ in range(30):
response = requests.get(url, headers=headers, timeout=10)
response.raise_for_status()
match = next((e for e in response.json() if e["recipient"] == recipient), None)
if match:
return match
time.sleep(1)
raise AssertionError(f"No email received for {recipient}")Setup
- 1
Prepare the PNTR inbox
Create an email-enabled PNTR subdomain and generate an API token. Put the token and subdomain ID in the test runner's secret environment, not in the repository.
- 2
Generate a per-test address
Create an address such as selenium- plus a UUID at your PNTR subdomain. No inbox setup is required for each local part because PNTR receives them all.
- 3
Drive only your application with Selenium
Enter the generated address, submit the form, and assert the application's immediate success state with WebDriver's normal explicit waits.
- 4
Poll PNTR outside the browser
Use your language's HTTP client to query PNTR until the exact recipient appears. API polling is faster and less fragile than opening a third-party mailbox with WebDriver.
- 5
Continue the browser journey
Fetch the matching email body, extract the expected link or code, then return to Selenium to complete the verification flow and assert the final signed-in state.
Before you ship
Do not automate a Gmail or Outlook login as part of this test. It introduces another site's authentication, selectors, and anti-bot behavior into a flow that only needs the delivered message.