Using the Email Testing Feature
Autify’s [Email Testing feature] allows you to test all of the following procedures:
- Create a test email account (email address and mailbox)
- Confirm that the email, which was sent as a result of a user workflow, has been received
- Verify the content of the received email
- Confirm that the user can navigate to other web pages by following a link(s) within the email
Previously, testing all of these would have required several tools.
Although [Email Testing] is a very powerful feature on its own, there are some tips and tricks that can be use to further this features capabilities.
Email Testing in Practice
To learn the basics on how to record [Scenarios] using the [Email Testing] feature, please read the Email Testing article.
With the basics down, let’s look at how to create [Scenarios] with more advanced Email Testing methods.
Verify that the content displayed on a website is included in the body of an email
The following example is one a common use case for [Email Testing]:
- The user completes a workflow on a web page
- Your system sends an email as soon as the workflow is completed
- Autify verifies that the email contains the same string as what is displayed on the completion screen
This is commonly seen in [Scenarios] that verify online ordering or booking processes. What's the best way to create a [Scenario] to test these processes?
Here are the steps:
Record the test until the point where the web page displays the target string.
Continue recording the Scenario until an email is sent. Then, open the target email to inspect from the Autify Recorder.
Record an assertion for the text within the email and save the [Scenario].
From the Scenario Details Page, click on the step in which you want to input the captured string. Select “Other step’s result” in the "Text" section dropdown and specify the [JS Step] which you created.
By creating a Scenario following these steps, you can verify that the email contains the string displayed on your website!
Enter the text from an email into a webpage
What if you want to enter the text contained in an email to your web app? A common instance where this is utilized is when verifying a two-step authentication code sent via email. You can see how to facilitate this workflow by viewing the How To Test Two-Step Verification via Email With Autify article.
Transition to the original screen or a specific page after opening an email
The [Email Testing] feature will open the specified email in the browser window you are recording on. If you wish to return to the website after verifying the email contents, please bear in mind you cannot record the clicking of the Back or Forward button in the browser. Instead, please record one of the following operations:
Method 1 : Go back to the previous screen using a [JS Step]
- On the Scenario Details Page, insert a [JS Step] where you want to go back to the screen before opening the email and insert the following script:
Method 2 : Open the email in a new window
- Before opening the email, add a Go to URL step with the "Open in new window" checkbox enabled (you can use any URL).
- Open the email in the newly opened window and continue recording any necessary assertions.
- Close the window you opened the email in. This will take you back to your original web page.
If you wish to go to a specific page after opening the email, please record the following:
- Add a Go to URL step after the step which opens the email, and specify the URL of the page you wish to navigate to.
- The specified page should then launch.
If a link is included in the email, you navigate to the linked page in the same window by clicking the link and from there, can continue the email flow and carry on recording.
Tips for Creating Stable Scenarios
When creating a [Scenario] using the [Email Testing] feature, here are a few things to keep in mind when creating tests, so that you get stable results.
Correctly Choosing Between Fixed and Random Email Addresses
The first step to using [Email Testing] effectively is to pick between a [Fixed email address]
or a [Random email address] based on the type of Scenario you wish to create.
Please see the following article on how to choose a suitable email address:
Always open emails sent by an operation in Scenarios
If operations from a [Scenario] send multiple emails, please avoid letting multiple unread emails sit in the inbox. You can ensure that the intended email is opened by opening all emails sent during a [Scenario] as they are received, so that the inbox always has only one unread email each time.
For scenarios that may be executed simultaneously, use separate fixed email addresses
If you choose to use a [fixed email address], please be careful not to send multiple emails to the same inbox around the same timeframe. If you use [email testing] in multiple [scenarios] that may be executed simultaneously, we recommend using a separate [fixed email address] for each [scenario]. Alternatively, you could opt for a [random email address].
Sometimes unexpected errors occur when you run a [Scenario] that includes [Email Testing]. Here are some common issues.
Autify couldn't find email during test execution
Please see here for information on the causes of "Email not found" and how to respond it.
The email opened during test execution was not the one that which was intended
- Multiple emails were received within the same [Scenario], and out of those, an unintended email was selected
- The target email was opened by another [Scenario] that was being executed simultaneously, and a similar email, which remained in the inbox, was opened instead (if using a [fixed email address])
In both cases, this issue can often be resolved by following the tips on creating [scenarios] described above.
An email in the inbox cannot be opened when making additional recordings
Autify’s [email testing feature] only opens emails in the inbox once (only unopened emails are considered during test execution). Therefore, if you are making additional recordings after the step that opens the email, please perform a [local replay], including the step where the email is sent.
If you continue to encounter issues when using the [Email Testing] feature after reading this guide, or have any feedback regarding this feature, please feel free to contact us!