Ƭrivumo Docs
Ƭrivumo Docs
HomeMCP Server
CypressJest + SeleniumMocha + SeleniumPlaywrightPytest + PlaywrightPytest + SeleniumRobot FrameworkWebdriverIO
Examples

Pytest + Playwright

Learn how to test email workflows using Trivumo and Pytest with Playwright.

Use Trivumo with Pytest and Playwright to test end-to-end email workflows such as account verification, password resets, magic links, and OTP authentication.

Install

pip install trivumo pytest pytest-playwright
playwright install

Create a Client

from trivumo import TrivumoClient

trivumo = TrivumoClient(
    apiKey="your_api_key",
    domain="sandbox.trivumo.com",
)

Verify Email Signup Flow

from playwright.sync_api import Page, expect
from trivumo import TrivumoClient


def test_verify_email_signup_flow(page: Page) -> None:
    trivumo = TrivumoClient(
        apiKey="your_api_key",
        domain="sandbox.trivumo.com",
    )

    email = trivumo.generate_email()

    page.goto("https://example.com/signup")

    page.get_by_label("Email").fill(email)
    page.get_by_label("Password").fill("Password123!")
    page.get_by_role("button", name="Create account").click()

    message = trivumo.wait_for_message(
        {
            "to": email,
            "subject": "Verify your account",
        }
    )

    verification_link = message.html.links[0].href

    page.goto(verification_link)

    expect(
        page.get_by_text("Email verified")
    ).to_be_visible()

Password Reset Flow

from playwright.sync_api import Page, expect
from trivumo import TrivumoClient


def test_password_reset_flow(page: Page) -> None:
    trivumo = TrivumoClient(
        apiKey="your_api_key",
        domain="sandbox.trivumo.com",
    )

    email = trivumo.generate_email()

    page.goto("https://example.com/forgot-password")

    page.get_by_label("Email").fill(email)

    reset_requested_at = trivumo.wait_for_message_after(
        {
            "to": email,
            "subject": "Reset your password",
        }
    )

    page.get_by_role(
        "button",
        name="Send reset link",
    ).click()

    message = reset_requested_at

    reset_link = message.html.links[0].href

    page.goto(reset_link)

    page.get_by_label("New password").fill(
        "NewPassword123!"
    )

    page.get_by_role(
        "button",
        name="Update password",
    ).click()

    expect(
        page.get_by_text("Password updated")
    ).to_be_visible()

Magic Link Login

from playwright.sync_api import Page, expect
from trivumo import TrivumoClient


def test_magic_link_login(page: Page) -> None:
    trivumo = TrivumoClient(
        apiKey="your_api_key",
        domain="sandbox.trivumo.com",
    )

    email = trivumo.generate_email()

    page.goto("https://example.com/login")

    page.get_by_label("Email").fill(email)

    page.get_by_role(
        "button",
        name="Send magic link",
    ).click()

    message = trivumo.wait_for_message(
        {
            "to": email,
            "subject": "Your magic login link",
        }
    )

    magic_link = message.html.links[0].href

    page.goto(magic_link)

    expect(
        page.get_by_text("Dashboard")
    ).to_be_visible()

One-Time Password (OTP)

from playwright.sync_api import Page, expect
from trivumo import TrivumoClient


def test_otp_verification(page: Page) -> None:
    trivumo = TrivumoClient(
        apiKey="your_api_key",
        domain="sandbox.trivumo.com",
    )

    email = trivumo.generate_email()

    page.goto("https://example.com/login")

    page.get_by_label("Email").fill(email)

    page.get_by_role(
        "button",
        name="Send code",
    ).click()

    message = trivumo.wait_for_message(
        {
            "to": email,
            "subject": "Your verification code",
        }
    )

    otp_code = message.html.codes[0]

    page.get_by_label(
        "Verification code"
    ).fill(otp_code)

    page.get_by_role(
        "button",
        name="Verify",
    ).click()

    expect(
        page.get_by_text("Verification successful")
    ).to_be_visible()

Validate Email Content

from trivumo import TrivumoClient


def test_validate_email_content() -> None:
    trivumo = TrivumoClient(
        apiKey="your_api_key",
        domain="sandbox.trivumo.com",
    )

    email = trivumo.generate_email()

    message = trivumo.wait_for_message(
        {
            "to": email,
            "subject": "Welcome",
        }
    )

    assert message.subject == "Welcome"

    assert (
        "Getting Started"
        in message.html.body
    )

    assert any(
        "/onboarding" in link.href
        for link in message.html.links
    )

Best Practice

When testing workflows that trigger an email, prefer wait_for_message_after() instead of wait_for_message() whenever possible.

page.get_by_role(
    "button",
    name="Send reset link",
).click()

message = trivumo.wait_for_message_after(
    {
        "to": email,
        "subject": "Reset your password",
    }
)

This ensures only emails received after the action are considered, preventing false positives caused by previously received messages in the inbox.

This is especially useful for password resets, magic links, invitations, and OTP-based authentication flows where multiple emails may be sent to the same address during a test run.

Playwright

Learn how to test email workflows in Playwright using Trivumo.

Pytest + Selenium

Learn how to test email workflows in Pytest and Selenium using Trivumo.

On this page

InstallCreate a ClientVerify Email Signup FlowPassword Reset FlowMagic Link LoginOne-Time Password (OTP)Validate Email ContentBest Practice