Software Quality Assurance & Testing Stack Exchange is a question and answer site for software quality control experts, automation engineers, and software testers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have been hearing a lot about page object modelling? Why is it so important?

Can someone please outline me page object model?

I'm currently working as QE in webservices area

share|improve this question
You can find additional info in my answer to this post:… – Sam Woods Oct 25 '12 at 15:43
This gives a good insight on the topic: Also there are quite a few articles on the topic online, so is there anything specific you are looking for or just a general idea of people's view? – Suchit Parikh Oct 25 '12 at 16:42

Read this ( scroll down to the page objects section though the whole page us good ) and this for some background

Or from this page

Taking it back to basics, essentially there are three functions I see a page object pattern provides:

Ability to easily instantiate pages in a consistent manner

Ability to concisely describe elements on a page, keep it DRY by avoiding repetition of element identifiers (using the underlying driver’s API)

Ability to provide higher level methods that use the elements to perform user oriented functions.

and a tutorial here

share|improve this answer

Your question hints at a couple of questions:

What Is a Page Object?

A page object is code written to model an actual page (or part of a page) in a web application. Eg. each page in your app, would have an associated page object file that provides the “services” that the actual page offers. Eg. if there’s a button on a page in your application, you would have a reference to that button in your page object. If you then write a test that clicks that button, you would access the button through the page object.

Why Use Page Objects?

Page object provide many benefits, including:

  1. Make tests more readable/easier to understand
  2. Make tests easier to maintain
  3. Help organize code into logical chunks

How To Use Page Objects

I have an example of the page object pattern I use in Sahi, written in Javascript on my blog. It walks through the included, working source code, which might help solidify the concept.

share|improve this answer

A Page Object approach can be thought of as giving and using names for commonly used pieces of HTML pages.

For example if you identify a button in three places this way:


There are now three problems:

  1. It's hard to read
  2. It repeats some element/attributes that might change
  3. Any updates would have to be done in 3 places.

A Page Object approach solved this by giving the HTML DOM identifying elements/attributes a name, for example


Then this is used in the code, e.g.


and when it needs to updated for example to be a div instead of a button you can just update


Store these defintions in one place and include them in the test spec and then the spec doesn't need to change when the page does.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.