Learn about POM in Maven

Use BrowserStack to run automated tests across real devices by configuring Maven dependencies for Selenium.

Get Started free
Home Guide What is POM in Maven

What is POM in Maven

By Sandra Felice, Community Contributor -

POM (Project Object Model) serves as the backbone of Apache Maven, offering a standardized way to manage a project’s build process, dependencies, and other configurations.

This article will give you a better understanding of POM in Maven.

What is POM in Maven?

POM (Project Object Model) is one of the fundamental concepts in Apache Maven that defines the structure and configuration of a Maven project.

POM in Maven represented by the pom.xml file, which contains information about the project, such as group ID, artifact ID, and version number, to uniquely identify the project.

It also defines the build process, detailing source directories, output locations, and any necessary plugins.

In short, the POM file is the backbone of a Maven project, controlling everything from dependency management to build automation, making it a crucial tool for seamless project execution and delivery.

Below is an example that includes only essential dependencies for Selenium and TestNG:

<project xmlns="http://maven.apache.org/POM/4.0.0"

         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

    <modelVersion>4.0.0</modelVersion>



    <groupId>com.example</groupId>

    <artifactId>selenium-basic-pom</artifactId>

    <version>1.0-SNAPSHOT</version>



    <dependencies>

        <!-- Selenium WebDriver dependency -->

        <dependency>

            <groupId>org.seleniumhq.selenium</groupId>

            <artifactId>selenium-java</artifactId>

            <version>4.8.0</version>

        </dependency>



        <!-- TestNG dependency -->

        <dependency>

            <groupId>org.testng</groupId>

            <artifactId>testng</artifactId>

            <version>7.5</version>

            <scope>test</scope>

        </dependency>

    </dependencies>



    <build>

        <plugins>

            <!-- Maven Compiler Plugin -->

            <plugin>

                <groupId>org.apache.maven.plugins</groupId>

                <artifactId>maven-compiler-plugin</artifactId>

                <version>3.8.1</version>

                <configuration>

                    <source>1.8</source>

                    <target>1.8</target>

                </configuration>

            </plugin>

        </plugins>

    </build>

</project>

Here:

  • Selenium WebDriver Dependency: Provides WebDriver support for interacting with browsers.
  • TestNG Dependency: Adds the TestNG framework for running tests.
  • Maven Compiler Plugin: Ensures the project uses Java 1.8 (you can change this based on your JDK version).

BrowserStack Automate Banner

What is the use of pom.xml in Maven?

pom.xml (Project Object Model) is a fundamental file in Maven that defines the configuration, dependencies, and project information required for building a Java project.

This file contains details about the project and its dependencies (libraries or frameworks), plugins, goals, and build lifecycle. By managing dependencies in the pom.xml file, Maven automatically downloads the required libraries during the build process.

This pom.xml file manages the Selenium and JUnit dependencies for an automation project.

What is Super POM in Maven?

The Super POM is the default POM file that Maven uses when no specific pom.xml file is provided by the user. It acts as the parent POM from which all other POMs inherit basic configurations such as default build settings, lifecycle, and repositories.

Key Inheritance: Any custom POM file inherits configuration from the Super POM, which defines default settings, like the build directory and default plug-ins.

What is Minimal POM in Maven?

A Minimal POM is the most basic form of a pom.xml file required for Maven to execute tasks like building the project. It contains only the essential elements such as modelVersion, groupId, artifactId, and version.

These identifiers are required to describe the project, but dependencies and additional configurations are optional.

Example of Minimal POM:

<project xmlns="http://maven.apache.org/POM/4.0.0">

    <modelVersion>4.0.0</modelVersion>

    <groupId>com.example</groupId>

    <artifactId>basic-project</artifactId>

    <version>1.0-SNAPSHOT</version>

</project>

Conclusion

If you are a tester or a developer, you can seamlessly run automated tests across real devices and browsers by properly configuring Maven dependencies for Selenium in the POM file.

BrowserStack offers a real device cloud platform where you can access over 3500+ different devices, browsers, and OS combinations.

Talk to an Expert

BrowserStack Automate allows you to execute these Selenium tests on real devices directly from your Maven project, ensuring compatibility across different environments and delivering high-quality web applications.

Tags
Automation Testing Selenium

Featured Articles

What is Maven in Java? (Framework and Uses)

Maven Dependency Management with Selenium

Automation Tests on Real Devices & Browsers

Seamlessly Run Automation Tests on 3500+ real Devices & Browsers