Overview
TheWAIT_FOR_EMAIL step polls a test inbox until an email arrives or the timeout is reached. It supports filtering by sender and subject to handle multiple emails.
Parameters
Email address to check for incoming mail. Typically uses a variable from EMAIL_CREATE_INBOX.Example:
{{TEST_EMAIL}}Maximum time to wait for email arrival in seconds. Range: 1-300 seconds.
Filter emails by sender address (partial match supported).Examples:
noreply@- Matches any noreply address[email protected]- Exact match@company.com- Matches any sender from company.com
Filter emails by subject line (partial match supported).Examples:
Welcome- Matches “Welcome to our app”Reset- Matches “Password Reset Request”Order #- Matches any order confirmation
Variable name to store the received email data for extraction in subsequent steps.
Behavior
- Polling: Checks inbox every 2 seconds for new emails
- Filtering: Applies sender/subject filters if specified
- First Match: Returns the first email matching all criteria
- Timeout: Fails if no matching email arrives within timeout
- Data Storage: Stores complete email data if
storeAsis provided
Email Data Structure
The stored email data contains:- id: Unique email identifier
- subject: Email subject line
- from: Sender email address
- to: Recipient email address
- text: Plain text email body
- html: HTML email body
- headers: Message headers including Message-ID and Date
- received_at: Timestamp when email was received
Common Use Cases
- Waiting for account verification emails
- Catching password reset emails
- Receiving order confirmations
- Getting notification emails
- Handling multi-step email workflows
Examples
Basic Email Wait
- Step type: WAIT_FOR_EMAIL
- Inbox:
- Timeout: 30 seconds
- Store as: RECEIVED_EMAIL
With Subject Filter
- Step type: WAIT_FOR_EMAIL
- Inbox:
- Subject: “Verify your account”
- Timeout: 60 seconds
- Store as: VERIFY_EMAIL
With Sender Filter
- Step type: WAIT_FOR_EMAIL
- Inbox:
- From address: [email protected]
- Timeout: 45 seconds
- Store as: ORDER_EMAIL
Multiple Filters
- Step type: WAIT_FOR_EMAIL
- Inbox:
- From address: [email protected]
- Subject: “Welcome”
- Timeout: 30 seconds
- Store as: WELCOME_EMAIL
Extended Timeout for Slow Systems
- Step type: WAIT_FOR_EMAIL
- Inbox:
- Subject: “Weekly Report”
- Timeout: 120 seconds (for scheduled emails)
- Store as: REPORT_EMAIL
Best Practices
- Set Appropriate Timeouts: 30-60 seconds for most emails
- Use Filters: When expecting multiple emails
- Store Email Data: Always use
storeAsfor extraction - Handle Delays: Account for email delivery delays
- Specific Subjects: Use unique subjects when possible
Email delivery times can vary. Set timeouts generously to avoid flaky tests, especially in CI/CD environments.
Error Handling
Common causes:
- Email delivery delayed beyond timeout
- Filters too restrictive
- Application didn’t send email
- Wrong inbox address
- Increase timeout value
- Check filter accuracy
- Verify application behavior
- Confirm inbox address
The step returns the first matching email. Use specific filters to target the correct email when multiple matches are possible.
Troubleshooting
Debug Tips
- Remove Filters: Start without filters to see all emails
- Check Timing: Ensure email trigger happens before wait
- Verify Inbox: Confirm correct email address is used
- Log Email Data: Store and log email data for debugging
Common Patterns
Wait for any email (debugging):- Step type: WAIT_FOR_EMAIL
- Inbox:
- Timeout: 30 seconds
- Store as: ANY_EMAIL
Related Steps
- EMAIL_CREATE_INBOX - Create test inboxes
- EMAIL_EXTRACT - Extract data from emails
- Email Inbox Testing Overview - Complete email testing guide

