Content ITV PRO
This is Itvedant Content department
Learning Outcome
5
Use Maven commands to run automated tests
4
Explain the Maven build lifecycle phases
3
Understand the importance of pom.xml for dependency management
2
Identify the standard Maven project structure
1
Understand the role of Maven in test automation projects
Clean and Predictable Project Layout
project-name/src/main/javasrc/test/javasrc/test/resources pom.xml pom.xml: The Heart of Every Maven Project
org.seleniumhq.selenium
selenium-java
4.20.0This XML snippet adds Selenium WebDriver to your project automatically
Maven Lifecycle: Behind-the-ScenesAutomation
Deletes previous build files
Checks if project structure is correct
Compiles Java source code
Runs test cases
Bundles into JAR or WAR
Clean
Validate
Compile
Test
Package
Benefits You Get from Using Maven
Feature
Process Maven
Manual
CI Integration
Project Structure
Build Process
Dependency Management
Complex setup
Varies by developer
Custom scripts, inconsistent
Manual downloads, version conflicts
Works out of box
Consistent layout
Standardized commands
Automatic resolution
Using Maven in a Selenium Test Project
Configure pom.xml
Add Selenium and TestNG dependencies to your project
org.testng
testng
7.8.0Write Tests
Create test classes in src/test/java folder
@Test
public void searchTest() {
driver.get("https://google.com");
// Test code here } Run Tests
Execute with a simple command in terminal
mvn clean testMaven: Automate Setup, Focus on Testing
Standardizes your project
Consistent structure makes onboarding easier for new team members
Essential for scalable automation
Integrates with CI/CD pipelines for continuous testing
Action Step
Create a Maven project with Selenium and TestNG dependencies
No more manual JAR downloads or version conflicts
Manages dependencies & builds
Summary
5
4
3
2
1
Maven automates dependency management and project builds
A Maven project follows a standard folder structure
The pom.xml file manages dependencies and plugins
Maven lifecycle includes phases like clean, compile, test, and package
Maven integrates easily with CI/CD pipelines for automated testing
Quiz
Which file manages dependencies in a Maven project
A. config.xml
B. testng.xml
C. pom.xml
D. build.xml
Quiz-Answer
Which file manages dependencies in a Maven project
A. config.xml
B. testng.xml
C. pom.xml
D. build.xml
By Content ITV