Apache Maven is a software project management and comprehension tool. It is formally known as Build tool. This article will help you to setup project and integrate selenium with maven.Based on the concept of a project object model (POM), Maven can manage a project’s build, reporting and documentation from a central piece of information that is called
Based on the concept of a project object model (POM), Maven can manage a project’s build, reporting and documentation from a central piece of information that is called Central repository. Maven has its own repository where it keeps all plugin, jars etc. in commonplace in .m2 repository.
Relation with Selenium
We can create Maven project for writing script and create dependency-using POM.xml once dependency is set Maven will download all the dependent jar files automatically and in future if any update comes from Selenium or TestNG side it will simply update all the required changes.
Eclipse should be Juno(4.2) or Kepler(4.3) and If you are using Eclipse mars or neon then Maven comes by default so you can skip initial steps
Follow below steps for Eclipse Juno and Kepler
Step 2- Open Eclipse and Go to Help section then Click on install new software.
Step 3– Now enter the url which we copied from Eclipse site and follow below steps.
Step 4– Now select Maven check box and click next and accept agreement and finish.
Step 5– Installation will take some time and it may be asked for restart the eclipse.
After the restart, you can create Maven projects.
Integrate Selenium with maven
Step1- Open Eclipse then go to File then Click on New and select general project
Step 2– Now here you will get so many categories so from General Select Maven then Maven Project.
Step 3– Now click on create a simple project checkbox and click on Next button
Step 4– Please enter Group id (depends on you I have taken selenium.maven) and Artifact ID > Next
Step 5- Click Finish and wait for some time for project creation. Once the project is created you can see the maven project in left project explorer.
Step 6– Click on pom.xml and click on Source tab you will get the source code of pom.xml
Step 7- Now if want to integrate Maven with Selenium or any other tools then we need to add a dependency with Selenium.
So navigate to http://docs.seleniumhq.org/download/maven.jsp
Step 8– Selenium guys has provided maven dependency so we need to copy the below dependency
Step 9– Open pom.xml file and create <dependencies> tag and paste the dependency code inside <dependencies> tag
Note – Each tag should be closed like <dependencies> —-</dependencies>
Step 10- Let’s integrate the TestNG also in Maven project and Repeat the same steps as we did for Selenium
http://testng.org/doc/maven.html
Based on the concept of a project object model (POM), Maven can manage a project’s build, reporting and documentation from a central piece of information that is called Central repository. Maven has its own repository where it keeps all plugin, jars etc. in commonplace in .m2 repository.
Relation with Selenium
We can create Maven project for writing script and create dependency-using POM.xml once dependency is set Maven will download all the dependent jar files automatically and in future if any update comes from Selenium or TestNG side it will simply update all the required changes.
Eclipse should be Juno(4.2) or Kepler(4.3) and If you are using Eclipse mars or neon then Maven comes by default so you can skip initial steps
Follow below steps for Eclipse Juno and Kepler
Step 1- Open any browser and Copy below URL
Step 2- Open Eclipse and Go to Help section then Click on install new software.
Step 5– Installation will take some time and it may be asked for restart the eclipse.
After the restart, you can create Maven projects.
Integrate Selenium with maven
Step1- Open Eclipse then go to File then Click on New and select general project
Step 3– Now click on create a simple project checkbox and click on Next button
Step 4– Please enter Group id (depends on you I have taken selenium.maven) and Artifact ID > Next
Step 6– Click on pom.xml and click on Source tab you will get the source code of pom.xml
So navigate to http://docs.seleniumhq.org/download/maven.jsp
Step 9– Open pom.xml file and create <dependencies> tag and paste the dependency code inside <dependencies> tag
Note – Each tag should be closed like <dependencies> —-</dependencies>
Step 10- Let’s integrate the TestNG also in Maven project and Repeat the same steps as we did for Selenium
http://testng.org/doc/maven.html
<dependency><groupId>org.testng</groupId><artifactId>testng</artifactId><version>6.8</version><scope>test</scope></dependency>