WebDriver Introduction
A different way of automating the browser.
. Create a browser-specific driver to control the browser directly and have to do this for each browser
. Object oriented API
. Doesn’t need a real browser
. No JavaScript limitations
. No need for a server
A Page Object is a object oriented class that serves as an interface to a page of you AUT(Application Under Test). If UI changes, test don’t need to be change, only the code within the page object need to be changed.
How does it work?
. Each page is defined as it’s own class.
. Actions (including navigation) are representing as functions for a class
. Each function returns a new Page object, signifying what page the actions stops on.
. Tests only talk to the page objects
. Page objects only talk to the driver
. Elements on the page are stored as variables for the page object
. Class inheritance can be used to define functionality to a set of pages.
- Define a class for the Page Object model by creating a Python script with the name of the page.
The Page Object model can be implemented by creating classes, defining methods and properties, and only exposing the functionality from the application page that needed it for testing.