Model the application interface

The first step we have to take in implementing the page object model is that we have to model the user experience. This means that all page specific elements has to be extracted to separate classes. This will guarantee that all functionality will be scripted only once.

Getting ready
The tests drive the implementation of the page object. In this way, we never end up with unused page object code.

How to do it…

  1. Create a new class file and refer the name to the actual page from the test object, by opening the context menu on the src folder and select New > Class. Make sure you fill in a package name and class name. Package name should refer to the entire website and the class name should refer to the specific page.
  2. Import the Selenium package in order to use the functions in the API. The code will look like this:
package prestashop;

import org.openqa.selenium.*;

public class SearchPage {

}

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.