Page Object Model (POM) — The Pattern That Keeps Tests Maintainable
POM is a design pattern, not a feature. Each page is a Java class with locators as private fields and user actions as public methods. The test class then composes those actions into business flows.
public class LoginPage {
private final WebDriver driver;
@FindBy(id="email") private WebElement email;
@FindBy(id="password") private WebElement password;
@FindBy(css="button[type=submit]") private WebElement submit;
public LoginPage(WebDriver driver) { this.driver = driver; PageFactory.initElements(driver, this); }
public DashboardPage loginAs(String user, String pass) {
email.sendKeys(user); password.sendKeys(pass); submit.click();
return new DashboardPage(driver);
}
}
POM reduces duplication by 60-70% and makes your framework survive UI changes. Pair it with Page Factory (Selenium's @FindBy annotations) to keep locators declarative.
Selenium Grid 4 — Parallel & Cross-Browser Execution
Selenium Grid 4 (released 2021, stable since 2022) is a complete rewrite in terms of observability but the same Hub-Node concept. You can run it in three modes:
- Standalone — single-process, great for dev laptops
- Hub-Node — classic model, one hub routes to many nodes
- Fully distributed — Router + Session Queue + Event Bus + Nodes, designed for Kubernetes
For Docker-based CI, the official selenium/hub:4.18 and selenium/node-chrome:4.18 images start in seconds and scale horizontally. On Kubernetes, the Selenium Operator manages nodes for you.
CI/CD Integration: GitHub Actions Example
name: Selenium Tests
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with: { distribution: temurin, java-version: '17' }
- run: mvn -B clean test -Dsuite=regression.xml
- if: failure()
uses: actions/upload-artifact@v4
with: { name: allure-report, path: target/allure-results }
This job runs every PR, uploads the Allure HTML report on failure, and can be extended to post screenshots to Slack. For 1000+ tests, split the suite into smoke.xml, regression.xml, and sanity.xml and run them on a schedule.
Common Selenium Framework Pitfalls
- Hard-coded sleeps — use WebDriverWait with ExpectedConditions, never Thread.sleep(2000)
- Brittle XPath — prefer CSS selectors and data-testid attributes over absolute XPaths
- Tests that depend on order — TestNG preserve-order + thread-count > 1 will break them
- No screenshot on failure — always bind a TestNG Listener or JUnit Extension that captures WebDriver screenshot
- Skipping headless mode — run headless in CI (ChromeOptions.addArguments("--headless=new")) for 2-3× speedup
FAQ
Is Selenium a testing framework or a tool?
Selenium is a browser automation library. The "Selenium framework" refers to the architecture you build around it (WebDriver + TestNG/JUnit + POM + Grid + Allure). Selenium WebDriver alone won't give you a framework — you compose it with other tools.
What is the difference between Selenium 3 and Selenium 4?
Selenium 4 (released 2021) standardized on W3C WebDriver, added Selenium Manager for auto driver management, introduced relative locators (above/below/near), and shipped BiDi APIs for network interception. Selenium 3 used the legacy JSON Wire Protocol which has been deprecated.
Should I use Selenium or Playwright in 2026?
For new browser-only projects, Playwright is faster, has built-in auto-wait, traces viewer, and parallel execution. Selenium still wins for cross-language teams (Java/Python/C#), legacy enterprise apps, and projects already invested in Selenium Grid.
How long does it take to learn the Selenium framework?
With prior Java/Python knowledge, you can write stable Selenium tests in 2-4 weeks. Building a production-grade framework with POM, Grid, Allure, and CI/CD typically takes 2-3 months of guided practice.
What is the Selenium certification path?
There is no official Selenium certification, but employers recognise ISTQB CTFL + hands-on Selenium experience. Tutorsbot's Selenium training in Chennai covers ISTQB + Selenium + TestNG + Jenkins with placement support.