Selenium Java POM Framework from Scratch πŸš€

Learn to build a complete Selenium Java POM framework with Maven, TestNG, and ExtentReports step by step.

Selenium Java POM Framework from Scratch πŸš€
Automation Step by Step
33.6K views β€’ Feb 18, 2025
Selenium Java POM Framework from Scratch πŸš€

About this video

Selenium Java - Complete Framework
Maven, TestNG, ExtentReports, POM

We will learn:
Environment Setup: Installing necessary tools
Project Setup: Creating a Maven project
Adding Dependencies: Selenium, TestNG, Selenium Manager, Logging, Reporting …
Page Object Model (POM) Implementation
Execution with TestNG
Reporting

My project: https://github.com/Raghav-Pal/SeleniumAutomationFramework2025

Full Playlist - https://www.youtube.com/playlist?list=PLhW3qG5bs-L_zQUmcXPs0F_e159DZ8OrP

00:00 *TOPICS*
01:31 Project Setup: Installing necessary tools
Step 1 - Install Java JDK java -version
Step 2 - Install Maven mvn -version
Step 3 - Install Eclipse IDE (Releases - https://archive.eclipse.org/eclipse/downloads/)

08:58 Create a Maven Project in Eclipse
Step 4 - Open Eclipse - File > New > Maven Project
Step 5 - Add Dependencies in pom.xml
selenium-java
selenium-manager
testng
log4j
extent-reports

Step 6 - Run mvn -U clean install Eclipse - Rt click on project > Maven > Update

23:00 Setup Project Structure (POM)
Step 1 - Create the following framework structure in your project

selenium-framework
│── src/main/java
β”‚ β”œβ”€β”€ base
β”‚ β”‚ β”œβ”€β”€ BaseTest.java
β”‚ β”œβ”€β”€ pages
β”‚ β”‚ β”œβ”€β”€ LoginPage.java
β”‚ β”œβ”€β”€ utils
β”‚ β”‚ β”œβ”€β”€ ConfigReader.java
β”‚ β”‚ β”œβ”€β”€ Log.java
│── src/test/java
β”‚ β”œβ”€β”€ tests
β”‚ β”‚ β”œβ”€β”€ LoginTest.java
│── testng.xml
│── log4j2.xml
│── extent-config.xml
│── pom.xml

πŸ”Ή Benefits of This Structure
βœ… Modular – Easy to update individual components
βœ… Reusable – Page Object Model (POM) reduces duplication
βœ… Maintainable – Logs, reports, and configurations are separate
βœ… Scalable – Supports adding more pages and tests seamlessly

26:39 What is Page Object Model

31:45 Create Base Test Class
Step 1 - Under package base create a java class BaseTest.java
Step 2 - Add code to initialize the browser and handle test setup

package base;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
public class BaseTest {

protected WebDriver driver;

@BeforeMethod
public void setUp() {
driver = new ChromeDriver();
driver.manage().window().maximize();
driver.get("https://example.com");
}
@AfterMethod
public void tearDown() {
if (driver != null) {
driver.quit();
}
}
}

42:26 Implement Page Object Model (POM)
42:38 Step 1 - Under package pages create a java class LoginPage.java

package pages;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
public class LoginPage {
private WebDriver driver;

private By usernameField = By.id("Email");
private By passwordField = By.id("Password");
private By loginButton = By.xpath("//*[@id=\"main\"]/div[3]/button");


public LoginPage(WebDriver driver) {
this.driver = driver;
}
public void enterUsername(String username) {
driver.findElement(usernameField).sendKeys(username);
}
public void enterPassword(String password) {
driver.findElement(passwordField).sendKeys(password);
}
public void clickLogin() {
driver.findElement(loginButton).click();
}
}

58:21 Step 2 - Under package tests create a java class LoginTest.java

package tests;
import base.BaseTest;
import org.testng.Assert;
import org.testng.annotations.Test;
import pages.LoginPage;
public class LoginTest extends BaseTest {

@Test
public void testValidLogin() {
LoginPage loginPage = new LoginPage(driver);
loginPage.enterUsername("admin@yourstore.com");
loginPage.enterPassword("admin");
loginPage.clickLogin();
Assert.assertEquals(driver.getTitle(), "Dashboard");
}
}

01:05:36 Step 3 - Add testng plugin to Eclipse
01:10:41 Step 4 - Run the test as testng test can also run using mvn test
01:13:37 Step 5 - Check TestNG Reports

01:16:20 Create testng.xml file

Step 1 - Create a file under project and name it testng.xml

Your testng.xml file is a TestNG configuration file that defines how your test suite should be executed

Step 2 - Run the file or run with command mvn test
Step 3 - Check TestNG Reports

1:22:28 Element Locators & Browser Interactions Reference


β–¬β–¬β–¬β–¬β–¬β–¬β–¬

Share with all who may need this

If my work has helped you, consider helping any animal near you, in any way you can

Never Stop Learning
Raghav Pal



β–¬β–¬β–¬β–¬ USEFUL LINKS β–¬β–¬β–¬β–¬

βœ… ALL TUTORIALS - https://AutomationStepByStep.com/


πŸ™Œ Connect with Raghav:

* Ask Raghav: https://bit.ly/2CoJGWf
* GitHub: https://github.com/Raghav-Pal
* Udemy: https://www.udemy.com/user/raghav-pal-3/



Shorts Eng - https://bit.ly/3H9bifV
Shorts Hindi - https://bit.ly/3XY7XqN

➑️ Subscribe for more videos: https://www.youtube.com/@RaghavPal

β€”

Video Information

Views

33.6K

Likes

585

Duration

01:23:46

Published

Feb 18, 2025

User Reviews

4.7
(6)
Rate:

Related Trending Topics

LIVE TRENDS

Related trending topics. Click any trend to explore more videos.