Get an automation test with systems that require email validation

Tram Ho

I. Requirements:

Registration and login is a very familiar procedure in many systems. Meanwhile, many systems require email authentication when signing up for an account. When you tested the system, you should be familiar with this registration and authentication.

However, the number of personal emails is limited, so how can there be enough emails to test and retest this function, not to mention when testing the functionality behind, you need to log in, it can be said the number of emails must use is great. So we have disposable email services (basically one-time email), many of you are probably familiar with these services / systems, so now I would like to list a few websites that support disposable email. email:

Popular disposable email systems:

So how to do it?

Usually, disposable email you can enter the email name by yourself, after @ will use the domain of these systems. For example with qa.team, when registering we can use email [email protected] to register, then enter qa.team enter tam.nguyen and can receive emails as usual.

For temporary email system like https://temp-mail.org , the system will generate email for us, we just need to copy the email to register and return to the system to receive mail.

So how about doing automation with the system that requires email verification?

Similar to manual, we can do it on the UI layer. As for manual, we can do it with automation like that. Although these systems have support APIs, to get close to the user behavior, in this article I will use Selenium Java to implement automation right on the UI.

II. Use Selenium java to perform automate for the email verification system

Let’s try writing an automation project for our website https://playground.mailslurp.com/

1. Import the required libraries

First, let’s also create a demo project for this requirement. I use Maven project and add the necessary depedencies to: Here are just libraries of Selenium, TestNG and WebDriverManager to manage webdriver

2. Steps to register with verify email for demo website https://playground.mailslurp.com/

The manual steps here would look like this:

1. Sign up

register

2. Sign in

  • Enter the email you just registered
  • Enter the password
  • Click the login button
  • Successful login test

login

Likewise, embark on writing a class to run offline

2. Write a test class to automate the steps above

Here I have a class that uses Java, Selenium and TestNG to automate the above steps as follows:

Above, most of the commands have been explained in the comments, mostly performing the same steps as the manual. If you have any questions, you can google or leave a comment

Here, I just create a class written step by step, everyone applies it to their own framework

Referencies: https://github.com/npmtam/Automation-Testing-Articles/issues/2

Share the news now

Source : Viblo