Maven is dependency management tool i.e to execute the frameworks, we need the jar files. Maven helps user to keep the upto date jar file on the framework.

During runtime maven will check the version of the jarfiles present in the local system and compares with pom.xml file. If the latest version is available online then it downlaods them automatically and replaces the local version and then executes the framework.

If there is no internet connection or if the latest version is not available, then maven executes the framework with the jar files available in the local system.

To achieve above said, we have to follow below steps:

1. Install Maven
2. Add dependency
3. Integrate TestNG with Maven
4. Execute the framework

Types of Maven Repository

There are three types of maven repository we will discuss about them now on this tutorial.

Green : Download requests
Violet : Download of files
Blue : Download Request and download of files

Remote Maven Repository :
Remote maven repository is manages by the companies who own the software, but they will expose the maven software to the maven.

Selenium jars are availabke at openqa servers
TestNG, POI jars are available at apache server

Centralized Maven Repository :
This is a cloud sever owned by Maven, this server downloads all the latests jar files from the remote maven repositories.

Organization Level repository : All the required jars are downloaded to this sever from the centralized maven repository.

All the big multi-national companies follows this process, First of all we have to request the tool handling teams to review you dependency request, based on our request the tools handling teams reviews and downloads the jar files to organization level server if the jar file doesnot contain any malware.

Few organizations follows this and this step is optional, if your organization have this leven then you have use the proxies provided by the tools handling team.

Local Maven Repositories :
Itis the location where the jar files are stored by maven in the locak system, these jars are downloaded from the centralized maven repository.

Install Maven with Eclipse

Follow below stpes install maven in eclipse, but if you are using luna or above version you might have maven by default installed with your eclipse, if not follow below steps.

1. Click on the Help menu, and choose Eclipse Market place. eclipse-help-options

2. Search for Maven with Eclipse, you will get below software result. As i have installed already, so I will not get install option, for your case you will have to click install option. maven-integration-with-eclipse

3. Accepth the agreement and restart the eclipse, this may take a while.

Convert the Existing Java project to Maven Project

We have to follow below steps to convert the java project into maven project.

1. Right click on the java project
2. Go to configure option
3. Select convert to maven project

4. Click finish
5. Fill the details of the project keep version number as 0.0.1 and packaging as jar.

Create a maven project with Selenium Webdriver in Eclipse

1. File New > Project new-project-selenium-webdriver

2. Choose Maven Project from select project wizard and click Next. select-maven-project-selenium-webdriver

3. Check the Create Simple Project Checkbox and click Next button. create-simple-project-maven-selenium-webdriver

4. Enter GroupID and ArtifactID GroupID : will identify your project uniquely across all projects, so we need to enforce a naming schema. It has to follow the package name rules
ArtifactID : is the name of the jar without version.
Version : if you distribute the jar(end product) then you can choose any typical version with numbers and dots (1.0, 1.1, 1.0.1, ...).
Packaging : how yu want your end product, maven will export the prject as jar or war or any other type we mention.


5. Click finish, Maven takes few moments to create the project and pom.xml
6. Your sample project will look like below. sample-maven-project-structure

7. Open pom.xml, and click on the select the pom.xml tab on the right, You find the source code of the xml file. pom-xml-src-maven-selenium-webdriver

8. We can add our dependencies on this source file, before closing the project tag
For Example : Navigate to selenium site "", copy the dependency lines from the selenium site. selenium-dependency-maven
9. Paste the dependency on the pom.xml, inside the dependecies tag, if dependences tag is not there, add one. dependency-in-pom-maven-selenium

10. Similar way you can add TestNG dependency. testng-selenium-maven-dependency

11. Press Ctrl+S, maven starts to download all the jar files and dependent jar files as well. downloading-maven-selenium-testng-jars

12. Optional Steps (only incase of error) : Sometime when we try to download very latest version jars we may face below issue. maven-selenium-testng-error

13. If above error occurs you may not even able to run the code, to overcome the issue we have to use the stable version of the jar files. We may not get these details from the respective organizations site (selenium, testbg orgs) but we can get these detials from the maven repository site :, you can use google for faster navigation. selenium-server-maven-details

14. After providing right details on the pom.xml, press Ctrl+S to download all the dependent jar files. downloading-maven-selenium-testng-jars

15. Your maven repository should look like below after downloading dependencies. mvan-downloaded-jars-selenium-testng

16. Create package src/test/java package, then create a Java class class-under-src-java-maven

17. Write following code in that class, if you get no error then we have installed the maven succesfully.

									package sample;

									import org.openqa.selenium.WebDriver;
									import org.openqa.selenium.firefox.FirefoxDriver;
									import org.testng.annotations.Test;

									public class MavenTest {
										public void test(){
											WebDriver driver = new FirefoxDriver();
											System.out.println("Title of the page is : " +driver.getTitle());

18. Before running we have to make sure of the compiler, navigate to Window>Preferences>Java>Installed JREs default-jre-maven-compiler-selenium

19. If you have only jre as your Installed JRE, then we have to add our JDK. We will be using the jre present under JDK. Click Add button > Standard VM > Directory , set the JDK folder. Click finish jdk-installed-jre-maven
20. Set the jdk as default jre, and Click OK. jdk-as-default-jre-maven-selenium

21. Right click on the pom.xml > Run As >Maven:test pom-xml-run-as-maven-test

22. If the configuration is correct, then maven downloads all the dependency jars and starts executing the program downlaoding-jars-on-run-maven-selenium

23. You see the result on the console of the Eclipse and on TestNG result tab testng-maven-result-selenium

24. Go to the folder's path in explorer, You can find test-output folder, open the index.html file under test-output folder. testng-test-output-result-maven-selenium

I hope you reached still last step :)

Multi-level Inheritance in Java and Selenium

Comment / Suggestion Section
Point our Mistakes and Post Your Suggestions
  • Praveen Kumar
    This Maven lecture is too small. It does not explain for Maven life cycle, it variaous stages and How would U call testng xml in POM xml? I think unlike your other lecture, this one is too basic. 
    • karthiQ [ admin]
      Hi Praveen,
      We are sorry for inconvenience, we are currently working on protractor  due that we are not able to focus on webdriver part.
      We would be start working on Webdriver from 19 June 2018, You can see this page updated by 25 June 2018.
      We would firstly focus on API, Maven, Jenkins.
      Thanks for the suggestion