Parameterizing Page Objects

Page Object Parameterization allows you to define and modify parameters within a Page Object, making it easier to reuse the same Page Object across different test scenarios. Instead of hardcoding specific values, you can pass in new data during test execution, enabling flexibility without duplicating Page Objects.

Why Use Parameterization?

Parameterization is especially useful for scenarios where test data changes frequently, needs to be varied across test runs, or needs to check for both valid and invalid inputs.

For example:

  • If you have a login Page Object, you can parameterize the username and password fields.
  • This allows the same Page Object to test multiple login scenarios (different user roles, valid vs. invalid logins, etc.) without creating separate Page Objects for each case.

Modifying Parameters

  1. Open a Test: Navigate to the test case where the Page Object is being used.
  2. Click Modify Parameters: In the upper-right corner of the Page Object, select the Modify Parameters button.
  3. Add New Parameter: Click Add New Parameter to begin parameterizing.
  4. Select Step: Choose the step within the Page Object that should be parameterized.
  5. Select Attribute: Identify the specific attribute (e.g., input value, button text) to parameterize.
  6. Select Operator (Verify actions only)
    • For verification actions, choose an operator (e.g., equals, contains).
    • Leave this field blank for all other action types.
  1. Enter New Value: Provide the value that will override the original Page Object value for this step.
  2. Save Parameters
    • Add all required parameters, then click Save.
    • A confirmation message will appear indicating that the Page Object Parameters have been updated.

Executing with Parameters

  • On the next test execution, the updated parameter values will automatically be applied.
  • In the Browser Results tab:
    • Actions that used parameterized values will be marked with [Parameterized].
    • Hovering over the blue highlighted area will display the overridden value used during the test.

Note: when a parameterized attribute is used for Select actions, you will also need to set the Executor to Select by text in the test step settings.

Key Benefits

  • Reusability – One Page Object can cover multiple scenarios.
  • Efficiency – Reduces duplication by eliminating the need to create separate Page Objects for minor variations.
  • Flexibility – Makes it simple to swap values for different environments, roles, or test data sets.
  • Scalability – Simplifies handling large test suites by minimizing redundant Page Objects.
  • Improved Readability – Test steps remain cleaner since data is injected dynamically instead of being hardcoded.