How To Create Selenium Maven Project In Eclipse IDE | Selenium Tutorial

Create Selenium Maven Project In Eclipse IDE:

In the earlier post, we have see “Installation of Maven in Eclipse“. In this post, we will see How To Create Selenium Maven Project in Eclipse IDE.

Make sure TestNG is already installed. Check this out to see “How To Install TestNG In Eclipse” and this check this link for “TestNG Complete Tutorial

To create a project – Right click on Package Explorer and navigate through NewOther

Install Maven

Select Maven Project and click on NextInstall Maven

Select ‘Create a simple project‘ check box and click NextCreate Maven ProjectFill the Group Id, Artifact Id and click the Finish button

Create Maven Project Structure of the project looks as shown in the below image

Create Maven Project

In the maven project, we use POM file to add the required dependencies. Double click on pom.xml file and click on pom.xml tab

Create Maven Project

 

We need to add some dependencies related to Selenium WebDriver, TestNG in our Maven Project.

Create Maven Project

Create a TestNG class and generate testng.xml file. Check the below link to do this step.

How to create a TestNG class and generate testng.xml file

Create Maven Project

Copy the below code and place it in your NewTest class

testng.xml: testng.xml file looks like below. Copy and place it in your testng.xml

To run the project using testng.xml, right click on ‘testng.xml’ file and go to Run As – TestNG Suite

To run the project using pom.xml, we need to add some more entries in the pom.xml file. We need to add ‘maven-compiler-plugin’ and ‘maven-surefire-plugin’

pom.xml

To run the project using pom.xml, right click on ‘pom.xml‘ file and go to ‘Run As‘ – ‘Maven test

Result:

This way we create Selenium Maven Project in Eclipse. If you have any queries, please mention in the comments section below.

Sharing is caring.

Share on facebook
Facebook
Share on twitter
Twitter
Share on linkedin
LinkedIn

Like This Post?

We have a lot more where that came from?

We only send really good stuff occasionally, promise.

Rajkumar SM

4 thoughts on “How To Create Selenium Maven Project In Eclipse IDE | Selenium Tutorial”

  1. Hi,

    I created Maven project with TestNg. When I am trying to run it getting below error:

    “java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory”

    I added Selenium and TestNG dependencies in pom.xml

    Please look into it and help me with this.

    Thanks in advance!!!

Leave a Comment

Your email address will not be published. Required fields are marked *

Share on facebook
Share on google
Share on twitter
Share on linkedin
Share on whatsapp

Recent Posts:

Scroll to Top
API Testing eBook

DOWNLOAD FOR FREE