Page Object Pattern
Purpose
- Consolidates the code for interacting with any given UI element
- Allows you to model the UI in your tests
- Exposes methods that reflect the things a user see and do on that page, e.g.
- addItemToCart(), getPrice()
- getEntryTitle(), saveDraft(), publishEntry()
- Hides the details of telling the browser how to do those things
Results
- Test code is very readable
- No duplication of Selenium API calls
- Interactive documentation via Ctrl-Space
- Eminently reusable code
- Improved maintainability
- Provide opportunity to make test creation extremely quick (and maybe even fun!)
What else
- All Page Object methods must return a reference to Page Object
- If the “user action” moves the focus to a different page, the method should return that page object
- Otherwise, return the same page object
More Reading
Found a typo ? Something is wrong in this documentation ? Just fork and edit it !