Installing maven in eclipse and setting up selenium and TestNG dependencies

Sonal Dwivedi
2 min readMay 15, 2018

--

Why Maven?

  • Maven is used to define project structure, dependencies, build, and test management.
  • Using pom.xml(Maven) you can configure dependencies needed for building testing and running code.
  • Maven automatically downloads the necessary files from the repository while building the project.

Steps to download maven in Eclipse and create new maven project:

  1. Go to eclipse help menu and select Eclipse marketplace. Search maven and install “Maven Integration for Eclipse”. Click on finish to complete the installation.
  2. In eclipse IDE, create a new project by selecting File→ New→ Other from eclipse menu. On the new dialog select Maven→ Maven Project and click Next
  3. On the new Maven Project dialog choose your default workspace location and click Next.
  4. Let the archtypes get loaded and select “maven-archtype-quickstart” artifact (This will be the default selection) and click Next.
  5. Enter “FirstTest” in Group Id and Artifact Id and click Finish
  6. Eclipse will create FirstTest with following structure:

6. Right click on JRE System Library and select Properties option from the menu

7. On the Properties for JRE System Library dialog box, make sure Workspace default JRE is selected and click OK

8. Select pom.xml from Project Explorer. This will open in editor view with Overview tab highlighted.

9. Select pom.xml file and this will open the xml file in editor section

10. Add the Selenium, TestNG, dependencies to pom.xml in the <project> node by following below steps. Remove the JUnit dependencies if found in xml file.

  • Go to any browser and search selenium maven.
  • Choose https://mvnrepository.com/artifact/org.seleniumhq.selenium and select “Selenium Java”. This will list you all the available selenium jars with latest being on the top.
  • Select latest version (3.11.0) and copy from <dependency> till </dependency>. Paste it in pom.xml
  • Get TestNG dependency from the same repository and paste it in pom.xml. Change testng scope from test to compile.
  • After putting selenium and TestNG dependencies, do Ctrl+S to save the pom.xml file and you will see that all the selenium and TestNG jars have been downloaded under “Maven dependencies”.
  • Dont forget to create all <dependency> tags under <dependencies> tag

--

--

Sonal Dwivedi

Quality Assurance (Manual+Automation) @TNM, Passionate about Selenium