Everything we have built needs Maven dependencies. Here is the complete pom.xml that wires Selenium, TestNG, Log4j2, Apache POI, and Gson together. This is the exact pom.xml you would use in a real project.
<?xml version="1.0" encoding="UTF-8"?>
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.testerrank</groupId>
<artifactId>selenium-practice</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<selenium.version>4.25.0</selenium.version>
<testng.version>7.10.2</testng.version>
<log4j.version>2.23.1</log4j.version>
<poi.version>5.3.0</poi.version>
<project.build.sourceEncoding>
UTF-8
</project.build.sourceEncoding>
</properties>
<dependencies>
<!-- Selenium WebDriver -->
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>${selenium.version}</version>
</dependency>
<!-- TestNG -->
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>${testng.version}</version>
<scope>test</scope>
</dependency>
<!-- Log4j2 -->
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>${log4j.version}</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>${log4j.version}</version>
</dependency>
<!-- Apache POI for Excel -->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>${poi.version}</version>
</dependency>
<!-- Gson for JSON -->
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.11.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<!-- Maven Surefire — runs tests -->
<plugin>
<groupId>
org.apache.maven.plugins
</groupId>
<artifactId>
maven-surefire-plugin
</artifactId>
<version>3.5.2</version>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>
testng.xml
</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
<!-- Maven Compiler -->
<plugin>
<groupId>
org.apache.maven.plugins
</groupId>
<artifactId>
maven-compiler-plugin
</artifactId>
<version>3.13.0</version>
<configuration>
<source>11</source>
<target>11</target>
</configuration>
</plugin>
</plugins>
</build>
</project>Q: What dependencies does your framework use? Why Maven?
A: We use Maven as the build tool because it handles dependency management, compilation, test execution, and reporting in one tool. Our key dependencies are: Selenium 4 for browser automation, TestNG for test execution and data-driven testing, Log4j2 for structured logging, Apache POI for Excel data reading, and Gson for JSON data. Maven is preferred in enterprises because it integrates with CI/CD tools like Jenkins (mvn test is all you need), follows a standard project structure that every Java developer knows, and manages transitive dependencies automatically. Gradle is gaining popularity, but Maven is still the standard for test automation in most Indian IT companies.
Always use version properties in pom.xml (like ${selenium.version}) instead of hardcoding versions in each dependency. When you upgrade Selenium from 4.25 to 4.26, you change one line instead of hunting through the file.
Selenium 4.6+ includes Selenium Manager, which auto-downloads the correct ChromeDriver. You no longer need WebDriverManager as a separate dependency. One less thing to maintain.
Key Point: The pom.xml is the backbone of your project. It defines all dependencies, build plugins, and the default test suite. Use version properties for easy upgrades.