LOADING

Type to search

Selenium Tutorial TestNG

Adding required dependencies to Maven project

Share

In our previous post we focus on creating a simple maven project. Today we look into adding required dependencies for Maven project needed for selenium project.

First, let us look into the benefit of using Maven instead of creating a traditional project.

Maven is an open source build tool for automation and management.

 Key features of Maven:

  • Better project information, such as dependency lists, cross referenced sources using the pom file.
  • Runtime management of Dependency & Repository required.
  • Build plugins are used to perform specific goals. For Instance, compiler type and version can define using the compiler plugin.
  • We can add another project as a dependency to the project easily using the help of maven.
  • Will analyses the project dependency and enables you to build schedule modules in parallel.
  • Maven is able to build projects into predefined output types such as jar, war.

For executing maven project you need to first install Maven on your system. Follow this link on how to install Maven

Now let us focus on adding required dependencies to the project.

Open pom file under your project for adding required dependencies, then add the dependencies block to the file.

Fig.1Adding required dependencies

Maven public repositories for dependencies would be available here.

Let us fetch first search for selenium dependencies from a maven repository. There would be multiple repositories available, but we need to complete package so select first available option.

Fig.2

Here we might get details of latest alpha or beta versions, but look for the latest stable version (Fig.3) and add details to our pom file (Fig.5). For instance, while writing this post stable version is 3.141.59 (Fig.4).

Selenium-stableFig.3

Selenium-stable-versionFig.4

<!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java -->
<dependency>
    <groupId>org.seleniumhq.selenium</groupId>
    <artifactId>selenium-java</artifactId>
    <version>3.141.59</version>
</dependency>

Selenium-library-addedFig.5

Now add required dependencies for instance TestNG / JUnit for test execution, Apache POI for Excel utilities.

Similar way adds all required dependencies based on your needs.

Selenium-library-addedFig.6

Leave a Comment

Your email address will not be published. Required fields are marked *