Knowledgebase

The Page Object Pattern Print

  • softwaretestingqa, software, guide, howto, solution, zillionkinghost, hosting, support
  • 0

Encapsulating interface interaction.

WHAT IT IS

A class representing a screen, exposing what a user can do there.

WHAT IT CONTAINS

Element locators Methods performing actions Methods retrieving state

WHAT IT DOES NOT CONTAIN

Assertions.

WHY NOT

Assertions belong in tests, where the expectation lives.

WHAT IT PROVIDES

Interface changes confined to one place.

WHAT A METHOD SHOULD REPRESENT

A user action, not a click.

WHAT THAT LOOKS LIKE

Signing in, rather than typing into two fields and clicking.

WHAT METHODS SHOULD RETURN

The page object for wherever the action leads.

WHY

It makes navigation explicit and catches unexpected destinations.

WHAT TO NAME LOCATORS

After what they represent, not their selector.

WHAT SELECTORS TO USE

Attributes added specifically for testing.

WHY

They survive design changes and translation.

WHAT TO AVOID

Page objects with dozens of methods Objects representing fragments of pages inconsistently Waits scattered through methods

WHAT ALTERNATIVES EXIST

Screenplay and similar patterns, organising by actor and task.

WHAT MATTERS MORE THAN THE PATTERN

That interaction detail is not in tests.


Was this answer helpful?
Back

Are you happy with your experience? Leave us a review on Trustpilot.


Trustpilot