Here’s a quick intro to the Page Object Model Framework that we use extensively to build out large, scaleable test suites. There are also other frameworks that complement the Page Object Model framework and can prove to be extremely useful (and at times necessary) when implementing Test Automation.
Page Object Model Framework
To start off, a Page Object is an object that represents a web page in your app. It hides the technical details behind a more readable and business-focused facade, reducing the duplication of code and simplifying test maintenance. The Page Object Model Framework is a very commonly used test automation framework in the industry because of this, testing platforms are able to differentiate the logic of scenarios versus their implementation. Essentially, a page object should allow software to do & see anything that a human can. This ability to discern the differences between the two is what significantly lowers the amount of duplicated code.
The Page Object Model creates screens for mobile apps as objects in code, and the same page objects can be used in other tests. These screens encapsulate views with input fields, checkboxes, buttons, etc., and that encapsulation greatly helps with maintaining the test.
A Page Object wraps an HTML page with an app-specific API, which allows you to change the page elements without going through all of the HTML. This is a huge benefit with this framework because if the UI changes for any page, it is no longer required to change all of the tests, only the code within the Page Object.
Benefits of the Page Object Model
The order in structure of code becomes more clear and understandable, and with POM step definitions require less code, making them inherently easier to maintain. On top of that, as just explained, with the use of app-specific APIs any changes to the test are now far more direct.
Because of the screens that the Page Object Model generates, each view of the app has it’s own screen with all of the elements and objects of the page included.
All repetitive details that are required in more than one screen can be reused across the app, and are already encapsulated within one handy class, and this is where a huge amount of duplicate code can be reduced.
The page objects can be used cross-platform to work on both iOS and Android- given that the elements are the same. Since the views don’t change they can be applied across all step definition and steps.