Page Object Operations

A Provar Page Object Operation or PO Operation is a custom function defined to execute a Selenium Java code on a Page Object in Provar.  Use a PO Operation in your test case when you need to perform certain UI testing which is either not possible or too complex to achieve through Out Of Box Provar test APIs.  All you need to do is write the Java code in a function and call it in your test case on a Page Object.
Example Of Page Object Operation

To configure the filters on a custom Salesforce VF Page labeled ‘Entitlements Criteria Page’ (2nd screenshot below) where the filters data is defined in an excel sheet which has to be read and driven into the test case and subsequently on the UI.

Strategy

  • Identify the UI fields to be mapped and need for Page Object or Page Object Operations:

Since the UI is custom VF page, we need to define a PO and map the fields.  Looking at the UI, following fields can be easily mapped via the Test Builder using locators:

  1. New Milestone Criteria (Button clicked to open this screen)
  2. Milestone drop down
  3. Create Filter Logic
  4. Add Row
  5. Save

However, the fields – Field, Operator and Value are repetitive but do not form a table.  The locators for these fields under a column are not unique and thus have to be assigned a row index on the column locator as shown for the ‘Value’ column below.

Also since the data being read from the excel is dynamic, the number of rows to be filled is also not known before hand and thus needs to dynamic clicking the Add Row button.

Thus we shall create a Page Object Operation (function) on the Selenium Page Object which shall contain the logic to dynamically create the field row locators and click on Add Row depending upon the number of rows to be inserted.

  • Make the test case data driven:

We shall read the data from the excel sheet and pass them into the above PO Operation using a Foreach loop.
Implementation

Step 1: Create a test case invoking the Salesforce Connection and launch the Test Builder.
Step 2: Read the Excel sheet for the data to be entered in the filters.
Step 3: Go to the ‘Entitlement Criteria Page’ and one by one map the 5 fields as defined in the strategy using the ‘ADD’ operation of the Test Builder creating a new Page Object (MilestoneVFPage in our example).  Example of ‘Save’ button being mapped is shown below followed with the screenshot of all 5 fields mapped.

Step 4: Open the file MilestoneVFPage.java from the navigator under Project->src->pageobjects.  Verify from the ‘Page Object Editor’ view that the 5 fields have been mapped. 

Step 5: Now from the ‘Java Source’ tab, create a new PO Operation as shown below
(Please zoom in your browser to see the code clearly)

Step 6: On the test case, add (drag & drop) the API ‘UI Action’ to create the test step to ‘Call’ the above PO Operation (function) under the ForEach loop passing the values read from the excel sheet as shown below.

Notice – The function parameters defined above (field, Operator, Value, Count) are being reflected as Inputs under ‘Interaction’ with the ‘Action’ = Call.

Step 7: Now order the test steps properly and debug & execute your test case to make sure all operations are performed successfully.

References for detailed Selenium help documentation:
http://www.seleniumhq.org/docs
https://newcircle.com/bookshelf/selenium_tutorial/index#introduction

2017-05-12T11:34:43+00:00

Leave A Comment