QA Automation Hub

Tutorials › What Is the Page Object Model (POM)?

What Is the Page Object Model (POM)?

By the QA Automation Hub team, powered by AtumCode · Updated 2026-11-20

The Page Object Model (POM) is a way to organise test code. Each page of the website gets its own class. The class knows how to find things on that page and what actions you can do there. The tests only say what should happen.

The problem without it

If the login button changes, you have to fix it in every test that uses it. With 50 tests that is a long afternoon.

A simple page object (JavaScript)

class LoginPage {
  constructor(page) {
    this.page = page;
    this.username = page.getByPlaceholder('Username');
    this.password = page.getByPlaceholder('Password');
    this.loginButton = page.getByRole('button', { name: 'Login' });
  }
  async login(user, pass) {
    await this.username.fill(user);
    await this.password.fill(pass);
    await this.loginButton.click();
  }
}

And the test:

test('valid login', async ({ page }) => {
  const login = new LoginPage(page);
  await page.goto('/');
  await login.login('Admin', 'admin123');
  await expect(page).toHaveURL(/dashboard/);
});

Good rules

The benefit is simple: when the page changes, you fix one file.

Want to practise this step by step?
Our free Enterprise Framework course teaches it in simple English, one day at a time.
Open the free course