Examples
Robot Framework
Learn how to test email workflows using Trivumo and Robot Framework.
Robot Framework can be combined with the Trivumo Python SDK to validate email-based authentication flows such as account verification, password resets, magic links, invitations, and OTP verification.
Install
pip install robotframework
pip install trivumo
pip install robotframework-seleniumlibraryCreate a Client
Create a Robot Framework library that exposes the Trivumo client.
TrivumoLibrary.py
from trivumo import TrivumoClient
class TrivumoLibrary:
def __init__(self):
self.trivumo = TrivumoClient(
apiKey="your_api_key",
domain="sandbox.trivumo.com",
)
def generate_test_email(self):
return self.trivumo.generate_email()
def wait_for_email(self, to_address, subject=None):
criteria = {"to": to_address}
if subject:
criteria["subject"] = subject
return self.trivumo.wait_for_message(criteria)
def wait_for_email_after(
self,
timestamp,
to_address,
subject=None,
):
criteria = {
"receivedAfter": timestamp,
"to": to_address,
}
if subject:
criteria["subject"] = subject
return self.trivumo.wait_for_message_after(criteria)Verify Email Signup Flow
*** Settings ***
Library SeleniumLibrary
Library TrivumoLibrary.py
*** Test Cases ***
Verify Email Signup Flow
${email}= Generate Test Email
Open Browser https://app.example.com/signup chrome
Input Text id=email ${email}
Input Password id=password Password123!
Click Button Create Account
${message}= Wait For Email
... ${email}
... Verify your account
${verification_link}= Set Variable
... ${message.html.links[0].href}
Go To ${verification_link}
Page Should Contain
... Your account has been verified
Close BrowserPassword Reset Flow
*** Settings ***
Library SeleniumLibrary
Library DateTime
Library TrivumoLibrary.py
*** Test Cases ***
Password Reset Flow
${email}= Set Variable existing-user@example.com
${timestamp}= Get Current Date
Open Browser
... https://app.example.com/login
... chrome
Click Link Forgot Password?
Input Text id=email ${email}
Click Button Send Reset Link
${message}= Wait For Email After
... ${timestamp}
... ${email}
... Reset your password
${reset_link}= Set Variable
... ${message.html.links[0].href}
Go To ${reset_link}
Input Password
... id=password
... NewPassword123!
Input Password
... id=confirm-password
... NewPassword123!
Click Button Reset Password
Page Should Contain
... Password updated successfully
Close BrowserMagic Link Login
*** Settings ***
Library SeleniumLibrary
Library TrivumoLibrary.py
*** Test Cases ***
Magic Link Login
${email}= Generate Test Email
Open Browser
... https://app.example.com/login
... chrome
Click Button Continue With Email
Input Text id=email ${email}
Click Button Send Magic Link
${message}= Wait For Email
... ${email}
... Sign in to your account
${magic_link}= Set Variable
... ${message.html.links[0].href}
Go To ${magic_link}
Page Should Contain
... Welcome back
Close BrowserOne-Time Password (OTP)
*** Settings ***
Library SeleniumLibrary
Library TrivumoLibrary.py
*** Test Cases ***
OTP Verification
${email}= Generate Test Email
Open Browser
... https://app.example.com/verify
... chrome
Input Text id=email ${email}
Click Button Send Code
${message}= Wait For Email
... ${email}
... Verification Code
${otp}= Set Variable
... ${message.html.codes[0]}
Input Text
... id=otp
... ${otp}
Click Button Verify
Page Should Contain
... Verification successful
Close BrowserIf the email only contains a plain-text body:
${otp}= Set Variable
... ${message.text.codes[0]}Validate Email Content
*** Settings ***
Library Collections
Library TrivumoLibrary.py
*** Test Cases ***
Validate Welcome Email Content
${email}= Generate Test Email
${message}= Wait For Email
... ${email}
... Welcome
Should Be Equal
... ${message.subject}
... Welcome
Should Contain
... ${message.html.body}
... Getting Started
${found}= Evaluate
... any("/onboarding" in link.href for link in $message.html.links)
Should Be True ${found}Best Practice
Prefer wait_for_message_after(...) for workflows that trigger a new email during a test.
message = trivumo.wait_for_message_after(
{
"receivedAfter": timestamp,
"to": email,
"subject": "Reset your password",
}
)It ensures only emails received after the action are considered, preventing false positives caused by previously received messages.