How to Create Selenium Maven Project In Eclipse IDE and add selenium & TestNg dependencies in Pom.xml
What is Maven?
Maven is a powerful build tool for Java software projects. It is used to build and manage projects written in Java, C#, Ruby, Scala, and other languages. It allows the developer to create projects using the Project Object Model and plugins.
In the maven project, a pom.xml file will be created and we have to add the dependencies in the pom.xml file.
Create a Selenium Maven project
To create the Maven project, the prerequisites are:
JDK should be installed in the system
Maven should be installed (By default it is already installed in the eclipse) but if not then go to the eclipse marketplace and search for the maven plugin.
Steps to follow to create the maven project
1. Go to the new > project:
A number of java projects will show from which select maven project and click on next button.
2. Again click on next button and now select the group id which is shown in below screenshot:
3. Again click on the next button and this time you will be asked to specify the name of the project in both the fields “Group Id” and Artifact Id”. Fill your project name in both the fields and then click on “Finish button”
4. Now, the maven project has been created and while expanding the project you will notice pom.xml file
Steps to add dependencies of selenium web driver and TestNG in Pom.xml
1. Open the pom.xml file and add below dependencies in the file:
<dependencies> <dependency> <groupId>org.seleniumhq.selenium</groupId> <artifactId>selenium-java</artifactId> <version>3.141.5</version> </dependency> <dependency> <groupId>org.testng</groupId> <artifactId>testng</artifactId> <version>6.14.3</version> <scope>test</scope> </dependency> </dependencies>
2. Save the pom.xml file and now you will notice all the respected jar files under the maven dependencies: