After creating a mabl Mailbox address, you can use it to create end-to-end tests that include email validation.
This article explains how to test emails in mabl Mailbox:
- Using a mabl Mailbox address in a form
- Creating an email assertion
- Opening an email
- Verifying attachments
Using a mabl Mailbox address in a form
To use a mabl Mailbox address in a form, take the following steps:
- Click on the plus icon at the bottom of the mabl Trainer window to add a step.
- Click on the Mailbox step.
- Select "Insert email address."
- Click on the input element where you wish to insert the mabl mailbox address.
Using a mabl Mailbox address
- Select the permanent or temporary email address from the dropdown in the Trainer window.
- Click OK to insert the email address into the input field you selected.
Once you submit your form and send the email, the message is sent to the mabl Mailbox.
Creating an email assertion
The next step is to check whether the email has been received:
- Click on the plus icon at the bottom of the mabl Trainer window to add a step.
- Click on the Mailbox step.
- Select "Open mabl Mailbox".
Opening mabl Mailbox
- In the mabl Mailbox modal, use the "Select inbox" dropdown to select the inbox you would like to test.
- Click on the Assert button next to the email you want to assert.
- In the Trainer window, confirm the email match criteria for the email you want to assert on.
- Configure the email assertion.
Opening an email
You can interact with the received email and follow links as if it were a typical page. To open an email sent to a mabl Mailbox email address, take the following steps:
- Click on the plus icon at the bottom of the mabl Trainer window to add a step.
- Click on the Mailbox step.
- Select "Open mabl Mailbox".
- In the mabl Mailbox modal, use the "Select inbox" dropdown to select the inbox you would like to test.
- Click on the Open button for the email you want to open.
Opening an email inbox
- In the Trainer window, confirm the email match criteria for the email you want to open.
Now you can test the rendered email as if it were any other page.
For mobile tests, the email opens in the device browser:
- On Android devices, emails open in Chrome.
- On iOS devices, emails open in Safari.
When you're ready to return to the app under test, use the "Navigate to primary app" button in the mobile toolbar to quickly navigate back to your original app.
Configuring email match criteria
When asserting and opening emails in the Trainer, configure email match criteria to ensure your test interacts with the correct email. Use strings or mabl variable syntax - {{@variableName}} - to match the following properties:
- Sender address
- Subject
- Body text
- Recipient address - permanent inboxes only
- Received within - permanent inboxes only
The inbox for a permanent email address is shared by every test that uses the same permanent email address. For this reason, if you use a permanent email address during concurrent runs, it is possible for an assert email or open email step to select an email that was sent by a different test run.
To mitigate this scenario, consider the following methods:
- Use the “Edit email match criteria” option to make email-related steps more specific about which email mabl should choose
- Avoid running tests concurrently if they send identical emails.
If the inbox contains multiple emails that match the configured criteria, mabl opens the most recently delivered matching email.
Verifying attachments
When viewing and interacting with the rendered email, you can also verify attachments to ensure that you're able to test every part of an email. mabl Mailbox supports:
- Inline attachments - Inline attachments are intended to be part of the email body
- Regular Attachments
The total email size must be less than 10 MiB. Since this includes all email headers and metadata, the attachment limit is also under 10 MiB.
Click on the link to the attachment to download it. mabl will automatically download the attachment and let you assert on it normally, as you would with any other download.
If the attachment is a PDF, the Trainer window asks if you would like to test the PDF. From here you can test your PDF as you would any other.
Attachment links expire after 1 hour. If you keep a mabl Mailbox open during training for over an hour, the links will not resolve. To refresh the attachment links, you can replay the trained test.
Exploring the Mailbox sandbox
Interested in learning more about mabl Mailbox? We recommend testing against the mabl sandbox app, which has a dedicated Mailbox section. To start trying it out, you can add an email address, subject, and body.
mabl sandbox Mailbox example
The mabl Mailbox stores the 100 most recent emails in the inbox.