Selenium Maven Dependency or JAR Files

Profile picture for user devraj

Maven is a build or project management tool. With the help of maven we can rectify any compilation issues within the framework whenever the people who are working on the same framework has added some files on the framework.

When we create a maven project in IntelliJ or Eclipse they create one pom.xml. In that pom.xml we have to add the dependencies required for Selenium project. With maven dependencies it is easier to maintain and update jars in the framework.

For example, a team is working on the same project and within the team, one member has updated the maven dependency to get the latest functionality. After updating the maven dependency in pom.xml. He/She committed the code in git branch and told his team members to get the latest code. So when they took the latest build. Latest jars will be automatically added in their system by maven.

Required Dependency for Selenium Project

  • Selenium Java/Server: Use Selenium-Server jar if you want to work with Grid otherwise java is fine.
  • TestNG or JUnit: Choice is your which framework you want to use, I will recommend TestNG since it has more control over test with additional annotations and listeners. 

Optional Dependency for Selenium Project

This we will add later to enhance our framework.

  • Reporting: Extent or Allure
  • Logs: Apache Common Logging, Log4J, SLF4J
  • Data Files Reader: Apache POI for Excel, Java XML parser, Database related dependencies etc.

So, There could be many depending on your requirement.

How to add dependency in project using maven

You can get the dependency from mvnrepository or from the official owner website. Below is the step using mvnrepository.

Step 1: Search dependency name for example "selenium maven dependency" through google or mvnrepository site search. Google will give you option for both mvnrepository site or official Selenium Website.

selenium maven depdency

Step 2: Look for the latest stable release on mvn repository website. Selenium website will also give you several option including alpha and stable release. Also it will give you depdendency for driver specific implementations.

selenium stable release

Step 3: Copy the dependency detail with groupid, artifact id and version and paste it to pom.xml inside <dependencies> tag.

selenium maven depdency

Similar way you can add TestNG or any other dependency.