Skip to main content

Overview

The Check Email step retrieves email content sent during your test execution. Use it to verify email delivery, extract verification codes, test OTP flows, and validate that your application sends the right emails at the right time.

When to Use Check Email

Use Check Email when you need to:
  • Test email verification flows: Verify that signup or login verification emails arrive correctly
  • Extract OTP codes: Retrieve one-time passwords or verification codes from emails
  • Validate email content: Check that confirmation emails, receipts, or notifications contain correct information
  • Test password resets: Verify password reset emails and extract reset links
  • Check transactional emails: Validate order confirmations, shipping notifications, or account updates

How It Works

Check Email retrieves emails sent to special test email addresses powered by Mailosaur. These addresses follow the pattern [email protected] and can receive real emails during test execution. You specify an email “slug” (the part before @), and the step retrieves the most recent email sent to that address. The complete email content - subject, body, links, codes, attachments - is stored in a variable you can use in subsequent steps. The step works with both static email slugs you define directly and dynamic email addresses generated by the Fill step’s Supatest Email feature.

Using the Check Email Step

When you add a Check Email step, you’ll configure:

Specifying the Email Address

You can specify the email address using expressions that reference environment variables or variables from previous steps: Static Email Slug Enter an alphanumeric slug directly (like testuser123). The step will check emails sent to [email protected]. Using Expressions Use expressions to reference:
  • Environment variables: {{env.EMAIL_SLUG}} - Use values from your selected environment
  • Variables from previous steps: {{vars.userEmail}} or {{vars['userEmail']}} - Reference email addresses generated earlier in your test
Important Notes:
  • Email slugs must be lowercase and alphanumeric only - no spaces, hyphens, underscores, or special characters
  • If your environment variable or variable already includes the full email address (with domain), it will be used as-is. Otherwise, the domain will be automatically appended
  • Use square bracket syntax {{vars['variableName']}} for variable names with special characters

Accessing Email Content

The step automatically creates a variable (like supatestMessage_0, supatestMessage_1) that stores the complete email. You can access:
  • Subject: The email subject line
  • Body: HTML and plain text versions
  • Links: All links in the email
  • Codes: OTP codes and verification numbers
  • Sender: From address and name
  • Attachments: Any attached files

Real-World Examples

This approach generates a unique email address for each test run, ensuring perfect test isolation. Step 1: Generate and Use Random Mailosaur Email Add a Fill step for the email field:
  • Use expressions and select {{random.mailosaurEmail()}}
  • Save that in a variable (userEmail)
Select Generate random data in Fill step Select Supatest Email (for OTP flow) option This generates an address like [email protected] and stores it in the userEmail variable. Step 2: Retrieve the Email Add a Check Email step and use an expression to reference the email variable:
  • Enter {{vars.userEmail}} or {{vars['userEmail']}} in the email slug field
  • The step will automatically extract just the slug portion if the variable contains the full email address
Add a Check Email step:
  • Toggle on “Use variable”
  • Select your email variable (userEmail) from the dropdown
Toggle on Use variable The step retrieves the email and stores it in supatestMessage_0. Step 3: Extract and Use the OTP Code Add a Fill step for the OTP input field and use an expression to extract the code:
  • Enter the correct expression, e.g. {{vars['supatestMessage_0']['html']['codes'][0]}} in the text field
Toggle on Use variable for OTP input Select email variable to create expression

Example 2: Static Email Address

Use this approach when you need a predetermined email address for testing. Step 1: Fill Email Field
Fill step:
  Locator: input[name='email']
  Text: [email protected]
Step 2: Check Email
Check Email step:
  Email Slug: testuser123
  (Auto-generates variable: supatestMessage_0)
Step 3: Extract OTP
Fill step:
  Locator: input[name='otp']
  Text: {{vars['supatestMessage_0']['html']['codes'][0]}}
Why this works: Simple and predictable, but multiple test runs to the same email can interfere with each other.
Step 1: Check Email
  Email Slug: userverification
  (Creates variable: supatestMessage_0)

Step 2: Navigate
  URL: {{vars['supatestMessage_0']['html']['links'][0]['href']}}

Step 3: Check URL
  Pattern: /verify
Why this works: Extract a verification link from an email and navigate to it to complete email verification.

Example 4: Verify Email Content

Step 1: Check Email
  Email Slug: orderconfirm
  (Creates variable: supatestMessage_0)

Step 2: Check Text
  Expected Text: {{vars['supatestMessage_0']['subject']}}
  Verify it contains "Order #12345"
Why this works: Validate that emails contain the correct information like order numbers or customer names.

Understanding Email Response Format

Supatest uses Mailosaur for email testing. The email variable contains a structured JSON object with all email details:
{
  "id": "77061c9f-da47-4009-9f33-9715a3bbf00c",
  "received": "2019-08-06T17:44:07.197781+00:00",
  "type": "Email",
  "subject": "Email subject line",
  "from": [
    {
      "name": "Acme",
      "email": "[email protected]"
    }
  ],
  "to": [
    {
      "name": "Jane Doe",
      "email": "[email protected]"
    }
  ],
  "html": {
    "links": [
      {
        "href": "https://example.com/signup",
        "text": "Sign Up Now"
      }
    ],
    "codes": [{ "value": "12345" }],
    "body": "Lorem ipsum..."
  },
  "text": {
    "links": [
      {
        "href": "https://example.com/signup",
        "text": "https://example.com/signup"
      }
    ],
    "body": "Lorem ipsum..."
  },
  "attachments": []
}

Common Expressions

Use these expressions in step fields (wrap in {{ }}): Extract first link URL:
{{vars['supatestMessage_0']['html']['links'][0]['href']}}
Extract link text:
{{vars['supatestMessage_0']['html']['links'][0]['text']}}
Extract OTP/verification code:
{{vars['supatestMessage_0']['html']['codes'][0]}}
Extract email subject:
{{vars['supatestMessage_0']['subject']}}
Extract sender email:
{{vars['supatestMessage_0']['from'][0]['email']}}
Using environment variables for email slug:
{{env.EMAIL_SLUG}}
Using variables from previous steps:
{{vars.userEmail}}
or with square brackets:
{{vars['userEmail']}}
For more advanced scenarios, see the Mailosaur documentation.

Best Practices

Choose the Right Approach

  • Use dynamic emails (Supatest Email feature) for maximum test isolation and parallel execution
  • Use static emails for simple, sequential testing scenarios
  • Use environment variables ({{env.EMAIL_SLUG}}) when slugs differ per environment
  • Use expressions ({{vars.userEmail}}) to reference email addresses generated in previous steps

Email Slug Guidelines

  • Always lowercase: Email systems are case-insensitive, use lowercase for consistency
  • Alphanumeric only: No spaces, hyphens, underscores, or special characters
  • Descriptive names: Use slugs that indicate purpose like signupverify or passwordreset
  • Unique per purpose: Different test scenarios should use different slugs

Timing Considerations

  • Email delivery typically takes 1-5 seconds
  • Add a Wait for Element before checking if needed
  • Consider network latency and email service processing time
  • Don’t check too quickly after triggering the email

Variable Management

  • Each Check Email creates a new auto-numbered variable
  • Use meaningful names when referencing email variables in expressions
  • Remember variable names for multi-email workflows
  • Document which email each variable represents

Troubleshooting

Email Not Found

Symptom: Check Email step fails to find an email Solution:
  • Verify the email slug exactly matches what your app sends to
  • Confirm emails go to @uoz0hbri.mailosaur.net domain
  • Wait longer for email delivery (add a Wait step)
  • Check that your application actually sent the email
  • If using dynamic email, verify the variable was captured correctly

Invalid Email Slug

Symptom: Error about invalid email slug format Solution:
  • Use lowercase letters and numbers only
  • Remove spaces, hyphens, underscores, or special characters
  • Don’t include the @uoz0hbri.mailosaur.net domain (just the slug)
  • Verify environment variables resolve to valid alphanumeric strings

Variable Dropdown Empty

Symptom: “Use variables” shows no options Solution:
  • Ensure you’ve used a Fill step with Supatest Email earlier in the test
  • Verify the Fill step ran successfully and created a variable
  • Check that the variable name matches exactly (case-sensitive)
  • Make sure the Fill step comes before the Check Email step
  • Remember: vars.* variables are resolved at runtime, so they won’t be validated in the frontend
  • Use square bracket syntax {{vars['variableName']}} if the variable name contains special characters

Expression Errors

Symptom: Can’t extract codes or links from email Solution:
  • Verify the email actually contains codes/links (check the email manually)
  • Use correct array indexing: codes[0] for first code
  • Check HTML vs text content (some emails only have one format)
  • Inspect the email variable structure to confirm paths

Timing Issues

Symptom: Step runs before email arrives Solution:
  • Add Wait for Element after triggering the email
  • Increase wait time if emails take longer to deliver
  • Check email service status if persistent delays occur
  • Verify network connectivity
  • Fill - Generate Supatest Email addresses for dynamic email testing
  • Navigate - Navigate to links extracted from emails
  • Wait for Element - Wait before checking emails
  • Extract Value - Extract values to use as email slugs