O'Reilly logo

Selenium Testing Tools Cookbook by Unmesh Gundecha

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Using the PageFactory class for exposing an operation on a page

In the previous recipe, we created the BmiCalcPage class, which provides elements from the BMI Calculator page to the test. Along with elements, we define operations or behaviors on a page. In the BMI Calculator application, we are calculating the BMI by entering height and weight values. We can create an operation named calculateBmi and call it directly in a test, instead of calling individual elements and operations.

In this recipe, let's refine the BmiCalcPage class and instead of elements, provide the operations that are supported on the page and some common properties. We will also move the WebDriver instance of the test to the BmiCalcPage class to make the test generic.

Getting ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required