The first Selenium page object class was created containing two getter and two setter methods. These methods, although not entirely object-oriented, are required to provide a way for the Selenium test classes to access a component inside the page object instance. This is a basic concept in Java called encapsulation. The data variables and objects in the class are hidden by making them private or protected, and only accessible outside the class using the getter methods, and so on.
As a general rule, we want to keep a separation between the page object and test classes. So, what happens if the user needs to access a button on the page to cancel some action or dialog from within the test class? They only have two choices: call the WebDriver class's findBy method and pass in a dynamic...