How to run your test using selenium and TestNG-Intellij IDEA

Why we use selenium with TestNG?

These two are very powerful automation tools which can make our lives easier while writing testcases. But default selenium is not providing user friendly reports for test. Using selenium with TestNG, we can generate more readable test results.

How we can start?

  1. As the first step, create a maven project in Intellij

File->New-> project->maven

maven project window

2. click on Next button and enter a project name,location,GroupId,Artifactid and Version.

3. Click on finish button and now you have a newly created maven project.

4. Add dependencies related to selenium and TestNG inside the newly created pom.xml

pom.xml with dependencies

How we can write test?

Example :Let’s assume we want to write a test case for login to an web application by a particular user.

  • user enter a valid ID
  • user enter a valid password
  • user logged in to the web application
  • Verify whether user logged in valid url
  1. Create a new Java class and add your test methods. Here is the sample I prepared.

Sample Output of test execution

Software Quality Assurance Engineer