Email Testing | Bondar Academy
Course: Mastering testRigor
Module: Advanced Tricks and Techniques
Instructor: Artem Bondar
Lesson Summary
In this lesson, we explore how to perform email testing using Test Trigger . There are two main use cases: Sending information from your test body to an email address. Validating received emails after actions such as user form submissions. Getting Started with Email Testing The Email Testing tab in the Test Trigger documentation provides various examples for working with emails. To send an email, follow these steps: Create a new test (e.g., verify email ). Update the email address (e.g., [email protected] ). Specify the subject and body of the email. Run the test to send the email. Validating Email Notifications For scenarios like user registration, you can validate the email sent to users: Fill out the registration form with a unique email address using Generate unique email . Click register to trigger the email. Use the prompt check that email to stored value to verify delivery. Important Considerations When testing email delivery: Use the testrigor-mail.com domain for testing notifications. Account for potential delays in email delivery by adding a wait time before validation. In summary, Test Trigger allows you to send and validate emails effectively, ensuring your application communicates correctly with users.
Video Transcript
In this lesson, we're gonna talk about how to perform email testing using Test Trigger. So generally, you have two main use cases. So the use case number one is when you need to send a particular information from your test body to some email address. And the use case when you want to perform the validation of the received email. For example, users submit some form and your application trigger sending the email. And you want to validate what's the content of that email. So Test Trigger can do both and in this lesson, we will talk about that. So let's get into it. So here in Test Trigger documentation, you can use this tab email testing for your reference. And here on this tab, you can find examples of different prompts, how you can work with emails. So let's start with the most simple example, how to send the email. I will take this prompt as an example and create a new test, sending a new email to my mailbox with desired subject and desired text. So I copy this prompt, going back to our framework and create a new test. For example, I call a new test, verify email and paste this prompt over here. Now I need to update the email address where I want to send the email. And in my example, I will use the email git user at bondaracademy.com. Then I can provide different subject, for example, test message and body. And this is the body that I want to send. Of course, this is a hard-coded information, but you can replace this with your, for example, stored value, stored variables inside of the test. For example, you want to send some details or some result of your test to email during the execution of the test. And this is when you can use this functionality. So if I simply click Add and Run, I expect that new email will be sent to my mailbox with the parameters that I have provided. All right, the test was completed. So we just opened the homepage and send the email with just dummy data. And if I go back to the mailbox and click on the email that we just received, we can see that this message was sent successfully. So hi, this is a test. This is the subject that we have provided. And it was sent from the domain testrigor-mail.com. So TestRigor reserve this domain, especially for the email testing. You will get emails from this domain, and you can interact with this domain when you want to test certain notifications. And this is the next example that we're going to talk about right now. So how about if your application during, for example, user registration is sending some email to this user, and then user have to interact with this email or get some code from this email or any other information. And you want to validate that your application can actually do that. And in this example, we will talk about this scenario. So going back to Playground application. And here, if I go back to auth and register, we have a registration form. So let's fill out this form and create a new user. For example, I call it test user. I will use the same email as get user at ponderacademy.com. We'll make some dummy password, test123123, for example, and test123123, click agree. Let's put some extra special characters and click register. And new user was created. And when we created a new user, we expect to receive email notification from our application the new account was creating. So going back to email, and here we go. This is the notification came from the application. So we see the message Playground NGX. And we see that message says, verify your account. So our application requires this user to verify the account. And then I click verify your account. And here we go. Email was successfully verified. So how about testing this scenario that we want to make sure that our application is sending email. And then we want to validate the content of this email. That, for example, message verify your account is displayed inside of the email. And then we want to click on verify your account button and then validate that after that email can be validated. So let's automate this scenario. And I will show you how you can use test trigger for that. So going back to the test, quick edit. I will comment out this one because we don't need it anymore. And we automate the scenario with the registration. So first step, we need to open homepage, then click auth and click register. So let's do this. Click auth, then click register. All right, the next step, when we're on the register page, we need to fill out this form. Enter, for example, test user into full name. Then we need to provide the email on the next step. But instead of providing the actual email that we were using before, we need to provide a test rigor email. So here, this domain testrigormail.com is the domain that we have to use to test this kind of notifications. So the email will be sent to the testrigor-mail domain. And then we will read the information from the mailbox related to the testrigormail.com. And we need to provide any unique and random email. For example, we can specify something like this. Enter something, something, something at testrigormail.com into email address. Into email address. And then expectedly, notification will be sent to this email. And testrigor will understand that we are looking for this particular email and will read this email for us. But hard-coding the email is not the best approach every time, so providing some random values. And the better way would be to use just a special testrigor command that automatically will generate for us a random email in this testrigormail.com format. So it's gonna be used this one. Generate unique email. Then enter into email address. And save as test email. Something like this. So this will automatically generate for us email address in needed format and will be saved as a variable in test email. The next step, what we need to do. We need to type the password. Enter testpassword123123 into password. And then we need to confirm the password as well. Into confirm password. So let's double check. So password, confirm password, capital P. Then we need to click on this agree. Click checkbox. Agree. And then last step, click register. So click register should click on this button for us. So let's quickly run this to make sure that this scenario is working and we can at least create a new user update and retest. All right, testpass, let's check the screenshot. And I think it works successfully. So we filled out the application. We see the random email typed into email address and the register button was clicked. All right, so let's move on. So after we clicked on register button, we expect that our application will send the email to verify your email here to this email address that we randomly generated. This is the test trigger email address. And the next step we need to validate is, first of all, if this email was received. So how we can test this? We can type a prompt, which is check that email to stored value. And this is the email was delivered. And let's run this test one more time. All right, testpass as well. And now look what we have on the screenshot. So after we click the register, we navigate it to the home page. And then test trigger opened for us the actual email that is received after we clicked the register. So now you can interact with the test trigger and you can see that the test trigger has opened for us. And we can validate any information inside of this email and we also can interact with elements. For example, verify your account button is also available to interact with. Here you can validate from which application is sent for and to the email address which we send the notification to. So let's run this test again. And now we can see that the email is sent to the correct address. Which we send the notification to. And now all we need to do is to perform the rest of the validation. That email was received, we know it for sure. Now we can validate that verify your account is displayed. That email is also displayed for this account and we can click on verify your account button. So let's do this as well. Quick edit. And now I need to add two more validations. Check that page contains verify your email. So let's check it out here. Verify your account. Verify your account. Roughly above. Roughly above your account information. Your account information. And also let's validate the email. Check that page contains stored value. Test email. Test email to the right of account. To the right of account. Then the next step after we perform this validation, we want to click on this verify your account button. Let's do this. Click verify your account. And after we click on this button, we expect this page to be displayed. And TestRigor will automatically open a new tab in the browser and switch to this tab if the new tab is open. So we need to validate that email is displayed. We need to validate that email is verified. Check that page contains email verified. All right, that's it. So let's quickly run this test one more time to see if it is working and validations are performed. All right, and test pass successfully. Let's check the screenshots. Your account. Verify your account. Your account information and email. We click verify your account button. And the next step, we validate it, email verified. So everything works as expected. One of the things that I want to point out is this step. So here, when we click the register, then we perform the step, check that email to stored value was delivered. So you need to consider how long does it take for your application for the email to be delivered. Because TestRigor will not wait for this condition by default. And if, for example, your system takes several minutes to deliver this email, you need to provide the additional wait before you perform this validation. For example, wait to deliver this email. Wait two minutes, something like this. If you have this delay. So it's your responsibility to make sure that you perform the validation if the email was delivered and interaction with this email when it was actually delivered based on your application conditions. So that's it. Let's quickly summarize what we did in this lesson. So in TestRigor, you can perform two types of email testing. So the option number one is when you just send the information to the desired email address from your test body, providing the subject and providing the body of the email. And if needed, you can provide the attachment. For example, to inform yourself or somebody else about the test execution or some intermittent test results. And the second example is when you need to test if your application is sending the email that is designed to do, for example, email notifications. In this example, you have to use the testrigor-mail.com domain for such testing. A good example would be to create, just generate unique email. And every time TestRigor will generate a test email just for a single test run. That way you will not have any concurrency issues in case you run the tests in parallel. After you perform the execution of your test, if it takes a little delay to deliver that email, you need to add this delay in your script. And after that, call this step, check that email stored value was delivered. TestRigor will open this email as a webpage, and then you can interact with this webpage, validating different information in this email or clicking on the buttons and interacting with this email normally as the webpage. All right, that's it guys. And see you in the next lesson.