top of page

What's pom.XML?

In this blog, we will learn about POM.XML.POM stands for Project Object Model. It is the fundamental unit of work in Maven. It is an XML file that resides in the base directory of the project as pom. xml. The POM contains information about the project and various configuration details used by Maven to build the project(s).

Why do we use POM files? Page Object Model, also known as POM, is a design pattern in Selenium that creates an object repository for storing all web elements. It helps reduce code duplication and improves test case maintenance. In the Page Object Model, consider each web page of an application as a class file—the pom. XML file contains information of project and configuration information for the maven to build the project such as dependencies, build directory, source directory, test source directory, plugin, and goals.

How to create a POM XML file in Selenium?

Creating a Maven project and adding the Selenium Dependency

  • Open Eclipse or any other IDE and ->Click on File->New->select Maven Project->select the checkbox to create a simple project->click on Next->-> Give the company name as a Group ID ( as " NumpyNinja") and Artifact ID as a project name (as "SampleProject") -> click on Finish.

  • Once a Project is created, a predefined folder structure, pom. XML is also created.

Open the pom. xml and navigate to the pom. ...

  • Add different dependencies and plugins inside the pom. xml as per the below structure.

What is dependency in pom.XML?

In the context of Maven, a dependency is simply a JAR file used by a Java application. Based on the POM file, Maven will download and add the JAR file to our Java path. Java will then be able to find and use the classes in the JAR file.

so now let's see

How do you add dependency in pom.XML?

To download the dependency jar for TestNG and Selenium, we should write a dependency code for all the tools in the pom.xml file. These are not only the dependencies that automation testers use. We may need to add some other dependencies based on the requirement to get the dependency code; go to the Google search, type "TestNG Maven dependency," and click on the link shown in the screenshots below.

Click on the latest Version, 7.8.0, as shown below in the screenshot.

Copy the dependency code of TestNG.

Paste it into the pom.XML file and click on to save button.

Note: You have put all of your dependencies inside of a single <dependency> tag. Each of them should have their own <dependency> tag, enclosed in a </dependencies> tag. For example:

<!-- TestNG Dependency --> <dependency> <groupId>org.testng</groupId> <artifactId>testng</artifactId> <version>${testng.version}</version> <scope>test</scope> </dependency> </dependencies>

What is Plugin in pom.XML?

  • Plugins are software components that extend the functionality of another software application. Plugins are used in many ways to test them with the Junits, creating jar/war/ear files, and documentation of the compiling code, clean,surefire,antrum(Runs a set of ant tasks from any phase mentioned of the build)

Following is the list of a few common plugins

Plugin & Description

  • clean: Cleans up target after the build. Deletes the target directory.

  • Compiler: Compiles Java source files.

  • Surefire: Runs the JUnit unit tests. Creates test reports.

  • Jar: Builds a JAR file from the current project.

  • War: Builds a WAR file from the current project.

  • javadoc:Generates Javadoc for the project.

  • antrun: Runs a set of ant tasks from any phase mentioned in the build.


Here, I used the maven-antrum plugin extensively in our examples to print data on the console. Refer Build Profiles chapter. Let us understand it in a better way and create a pom.xml in the C:\MVN\project folder.

Next, open the command console to the folder containing pom.xml and execute the following mv command. C:\MVN\project>mvn clean

Maven will start processing and displaying the clean phase of the clean life cycle.


  • Each plugin can have multiple goals.

  • You can define the phase from where the plugin should start its processing using its phase element. I am used clean phase.

  • You can configure tasks to be executed by binding them to the goals of the plugin. We've bound the echo task with the run goal of maven-antrum-plugin.

  • Maven will then download the plugin if not available in the local repository and start its processing.

I hope this blog helps you understand the different elements of your pom.xml.

Comments and feedback are most welcome.

Thanks for reading. Happy Learning 😊

61 views1 comment

Recent Posts

See All




nice very helpful

bottom of page