The Page Objects is a great pattern for automated testing of any GUI application, both desktop and web. In a nutshell the Page Object is a class that represents the page (or window for the desktop application) of the Application under the Test (AUT). The automated test interacts with the page through the page object instance.
The following example uses WebDriver, Java and TestNG and wil "test" the Google Mail login page.
First, we need to create a page object for the login page. We will use http://mail.google.com as the start page.
package demo.pageobects; |
Then we will use this page object in our test class:
package demo.pageobects; |
Of course this example is very simple. In your real test the login method should return the instance of another page object (i.e. InboxPage) or the new instance of the GmailLoginPage if login failed.