Page Objects are a way to reuse certain objects throughout JOSF. Using location strategies to find objects in test steps work great, until the buttons that you use in multiple test cases change. Page Objects provide a way to store location strategies in one place and reference to them from test steps.
For example, a login page which has at these three objects that are required to perform a login action; a username/email address input field, a password input field and a log in button.
By storing these three objects in JOSF and referencing them from test steps improves readability and maintainability. If ever the location strategy of any of these objects change, you now only need to update the location strategy from the page object, in stead of all those test cases where you use those objects.
Duplicate objects on a web page
Sometimes objects appear more than once on a web page. To help you find the exact object, there are two things JOSF offers to find the correct object;
- Multiple strategies
By using multiple strategies, JOSF combines the given strategies to a single location strategy. For example, there is a button on the with a Login value. Most probably, these two location strategies would then find the object.