Accessing email messages
Loadero offers functionality that allows receiving email messages during the test's runtime and access their contents. There are certain features that are impossible to test thoroughly without a valid, existing email. Registering a new account and resetting an account's password are two of the most prominent examples for such a feature.
The ability to receive email messages and access their contents is achieved through the usage of two commands within the test script - the "Generate Email Address" and "Receive Email" commands.
This page describes how to utilize this feature in general. For more technical details on implementing the commands in the script, refer to our custom commands documentation.
Preparing the email address
You cannot just use any email address in tests. It must be one generated via the "Generate Email Address" command.
The first step in processing any email message is setting up the actual email address that will be receiving them. You cannot use just any email address. This email address must be generated by using the "Generate Email Address" command in your test script. This is a security measure, as Loadero-generated email addresses are only valid within the context of the test run where they had been generated. Email messages received by an address generated during a Loadero test run will not be accessible outside the scope of that very same Loadero test run. They will not be accessible after the run has completed either, so if you wish to save email message contents for later, you may want to print them to the console so that these contents are saved in Selenium logs instead (though these logs will also expire eventually).
Refer to the command's documentation for details on what the generated email address would look like and which part of it you can customize.
You are not limited to generating just one email address in a test. You can generate as many as you need. However, within the scope of a single test run the generated email addresses will be uniquely identifiable only based on the prefix that had been provided to the command. As a result, if you generate an email address twice within a single test with the same prefix, both times you will produce the exact same email address.
If you want each participant to have their own email address, you can provide the participant's global ID when using the email generation command.
Generated email addresses are run-specific. You can execute two test runs with the exact same script, and each of these two runs will use different email addresses. Email messages received during the first test run will not be available to the second test run, and the two runs will not interfere with each other.
Fetching received email messages
After the email address has been generated, all messages received by this address can be fetched through the "Receive Email" command. This enables you to, for example, use the generated email address to fill out a registration form, and then fetch the email message that contains the verification link, allowing you to go through the full registration user journey within the same test.
The "Receive Email" command will fetch a collection of all email messages received by the specified email address. It is recommended to use a retry mechanism when waiting for a specific email message to appear. An example for how a retry mechanism could be implemented is provided in the command's documentation.
After fetching the email messages you may process them in the test script in whatever way you deem necessary, such as fetching a verification token after registering to a website or resetting your password.