Page Objects in Selenium 2 (WebDriver).

Web Testing box

Press Spacebar or Tab To Get Started

To view this presentation please use the latest Firefox, Chrome, or Safari browser.

Inspired by

page objects

This project is inspired by:
Ben Burton's WebDriver Best Practices
Dave Justin’s page object post
James Cox's Using Page Objects

Why Page Objects pattern?

Reduces the amount of duplicated code.   Encapsulate the internal state of a page into a single page object.

UI changes only affect to a single Page Object, not to the actual test codes.

Code re-use: Able to use the same page object in a variety of tests cases.

Step 1: Page Object base class.

PageBase class provides the base structure and properties of a page object to extend.

Step 2: Extends PagaBase

extends PageBase

Step 3: Navigation from Page to Page

1. When you're simulating having the user enter a new URL into the URL bar of the browser, then it's the responsibility of the test class to create the page object it needs.

test class

2. some operation on the page that would cause the browser to point to another page -- for example, clicking a link or submitting a form -- then it's the responsibility of that page object to return the next page object.

page to page navigation

Step 4: Tests with Page Objects

page object test example

Here are the source codes

Project Home:
PageBase source code
Page Objects test example

Thank you!

Chon Chung - @chon_chung

< >