Introduction
Java classes that are not Selenium page object classes, test classes, or data files, but support testing browser or mobile applications, can be considered utility classes. Most utility classes are static in nature, and use Java API methods that are not specific to any feature or test. They can include methods that operate on the browser or mobile device itself, but are not specific to the application running on them.
For example, the Selenium ExpectedConditions
class has common methods to synchronize tests against actions occurring on a page, but it doesn't matter what the pages are, browser or mobile. Utilities can be built for file operations in reading, writing, or deleting files during tests. Test listener classes can be built, leveraging the TestNG TestListenerAdapter
class, to log output to files and/or the console during test runs.
Other types of utilities that can be leveraged include image capture, JavaMail, third-party test listener and reporters, and JavaScript Executor...