You have been writing tests, and they work. But there is a ticking time bomb in your code. Look at how your tests are structured right now — locators and actions scattered across every test method. If a developer changes an element ID from "username" to "user-email", you have to update every single test that uses that locator. With 50 tests touching the login page, that is 50 places to fix.
Think of it like a phone book. If your friend changes their number and you have written it on 50 sticky notes around your house, you need to find and update all 50. But if you had one address book, you update it once. POM is that address book for your locators.
// WITHOUT POM — locators duplicated everywhere
public class LoginTests {
@Test
public void testValidLogin() {
driver.findElement(By.id("username")).sendKeys("testuser");
driver.findElement(By.id("password")).sendKeys("password123");
driver.findElement(By.cssSelector("button[type='submit']")).click();
Assert.assertTrue(
driver.findElement(By.id("welcome-message")).isDisplayed());
}
@Test
public void testInvalidLogin() {
driver.findElement(By.id("username")).sendKeys("wrong");
driver.findElement(By.id("password")).sendKeys("wrong");
driver.findElement(By.cssSelector("button[type='submit']")).click();
Assert.assertTrue(
driver.findElement(By.cssSelector(".error-message")).isDisplayed());
}
@Test
public void testEmptyUsername() {
driver.findElement(By.id("password")).sendKeys("password123");
driver.findElement(By.cssSelector("button[type='submit']")).click();
Assert.assertTrue(
driver.findElement(By.cssSelector(".error-message")).isDisplayed());
}
// Imagine 47 more tests like this...
// If "username" changes to "user-email" → update 50 places!
}| Without POM | With POM |
|---|---|
| Locators duplicated across every test | Locators defined ONCE in the page class |
| One UI change breaks dozens of tests | One UI change = one update in one file |
| Tests are hard to read — full of findElement calls | Tests read like user stories |
| No code reuse — same steps repeated everywhere | Page methods reused across all tests |
| Maintenance nightmare at scale | Scales to hundreds of tests easily |
| Quick to start but unmaintainable long-term | More setup upfront but saves time long-term |
Without POM, a single UI change (like renaming an element ID) can break dozens of tests. This is the #1 reason automation suites get abandoned. I have seen teams spend 3 months building a suite, then abandon it after 6 months because every UI update broke 30+ tests.
Key Point: Without POM, locators are duplicated everywhere. One UI change breaks dozens of tests.