33

What is page object pattern in Selenium WebDriver?

What is the use of it and how can we use this in Selenium WebDriver?

Example will be appreciated.

Ripon Al Wasim
  • 36,924
  • 42
  • 155
  • 176
bugCracker
  • 3,656
  • 9
  • 37
  • 58
  • 12
    A perfectly valid question. Doesn't make sense to close it. Reopen it to actually have more productive answers. – Deep Feb 22 '15 at 13:32
  • 3
    @Deep Indeed, the question does not ask for a ressource but for an explanation and should be reopened. On the other hand it seems not (re)searched at all so the quality is not very high. – NoDataDumpNoContribution Feb 26 '15 at 10:38
  • 1
    @Trilarion That's a valid point about "not having done enough (re)search".. – Deep Feb 27 '15 at 10:45
  • Follow single responsibility principle while designing your page objects - You will have a well readable and reliable tests - more info: http://testautomationguru.com/arquillian-graphene-page-fragments – vins Sep 20 '16 at 03:22
  • When looking for a definition of anything dev-related I always go for SO. I feel like the definitions/explanations on dev-blogs or in official documentations aren't generally very good. Way too lengthy, making it sometimes hard to distinguish what is important. – Jaroslav Záruba Oct 24 '19 at 16:05

2 Answers2

53

The documentation has already covered this. If you have any specific questions, feel free to edit your main post.

Official:

Unofficial: Do a Google search, you will get a lot info on this.

Yi Zeng
  • 32,020
  • 13
  • 97
  • 125
3

[Edited to respond to the reply below. And thanks, I'll do better.]

The purpose of the page object pattern is to completely encapsulate the testing interface to the web page. This follows the time-honored practice of data hiding.

Here's the Selenium article about the page object.

And here's my post "Keep Your Page Objects DRY".

Burdette Lamar
  • 229
  • 2
  • 13