Skip to main content

Applying advanced features of scenario tests

The new releases of Pega scenario testing include several advanced features such as configuring data dynamically on the test case steps, reusing one test case in another, testing the end-to-end flow based on the role of a user, capturing a value and reusing it in the same or a different test case, and recording non-out-of-the-box controls by using their XPath.

Configuring dynamic test data

The scenario-based testing framework allows values that the system generates as part of the setup configuration to apply to the user interface elements during playback. By default, a value that you provide to the UI element while creating and recording a test case is considered static. The system applies the same value during playback or when you run the test case.

However, when you use this feature, you can provide a different value dynamically to the field while running the scenario test case.

Use case: Consider a government application with the Add vehicle case type. This case type is used to add newly registered vehicles and other details to the database.

Problem statement: Create a test case to test the flow that records:

  • The initiation of this case type.
  • A flow for adding the details of a vehicle.
  • A flow for submitting the case.
  • A flow for asserting the success banner, which indicates that the vehicle has been added successfully.

Enter a unique registration number, which is one of the entered details; the flow fails if you enter a duplicate value. While recording a scenario test case, you enter a unique value to the registration number along with other details of the vehicle and proceed until the success banner is recorded.

However, while running the same test case, when the application applies the registration number that you entered during the recording, the flow fails with an error. As a result, you cannot see the success banner

Solution: In the case of an error that results from a duplicate registration number value, configure a dynamic value to enter the registration number field:

  1. Create an activity to generate a unique value and set the value to a property of a page.
    For example, if VehicleDetails is the page, then uniqueRegID is the property. VehicleDetails.uniqueRegID requires a unique value when you run the activity.
  2. Record a test case for one successful vehicle creation scenario.
  3. In the header of Dev Studio, click Configure > Application > Quality > Automated testing > Scenario testing > Test cases and open the test case which you recorded in Step 2.
  4. Click the Setup & Cleanup tab.
  5. In the Run other steps section, click Add step, and then, in the list, select Execute activity.
  6. Include the activity that generates a unique value on the property of a page. 
  7. On the Definition tab, in the Test case steps section, click the test case step for which you want to enter the registration number value.
    The details of the step are displayed on the right.
  8. In the Actions section, in the change event, in the Value type list, select Dynamic.
  9. In the Value field, enter the page property.
    For example, enter VehicleDetails.uniqueRegID.
  10. Save and run the test case, which applies a unique value for the registration number field in every run and asserts on the success banner.

Check your knowledge with the following interaction: 

Reusing scenario tests

You can reuse scenario tests and embed them within other scenario tests. By reusing scenario tests, there is no need to record the same test steps multiple times.

You can configure a scenario test case as reusable by selecting the Reusable checkbox on the Definition tab. As a result, you can now embed this test case in the setup of any other test case that is recorded on the same user portal. However, the scenario test case which has embedded test cases in the Setup section, cannot be marked as Reusable unless all the embedded test cases are deleted. Similarly, when you mark a test case as Reusable and save it, you cannot embed test cases in the Setup section unless you deselect the Reusable checkbox.

There is no limit to the number of reusable scenario tests that you can embed in a scenario test. When you run a scenario test with embedded scenario tests, the system runs the embedded scenario tests in the sequence in which the tests are displayed. Then, the system runs any other setup steps.

Use case: Consider a government application with the following case types:

  • Update vehicle
  • Add member to vehicle
  • Search vehicle

These case types are used to edit details of newly added vehicles, add members, enter proof of identity to a specific vehicle, and search a particular vehicle based on the registration number or vehicle type.

Problem statement: To test the case types in the use case, adding a new vehicle is a common scenario; you initiate the update, add a member, or search the flows. If adding a vehicle involves 30 steps, then these 30 steps are common across all three test cases, and having multiple steps for a single test case makes it difficult to debug and edit.

Solution: By using reusable test cases, record common steps among the three flows as a single test case; configure the test as a reusable test and embed where necessary:

  1. Create a test case to cover the scenario which adds a vehicle.
  2. In the header of Dev Studio, click Configure > Application > Quality > Automated testing > Scenario testing > Test cases and open the test case which you created in Step 1.
  3. On the Definition tab, at the top of the Scenario test case page, select the Reusable checkbox.
  4. Create separate test cases to cover the update, add-member, and search flows.
  5. Open the scenario test into which you want to embed the reusable scenario test.
  6. Click the Setup & Cleanup tab.
  7. Expand Embed and execute other test cases on start.
  8. Click Add scenario test case.
  9. In the Of class field, select the class to which the scenario test case belongs.
  10. In the Name of test case field, select the test case that you want to embed.
  11. Click Save.

For more information, see the release notes for Pega Test Automation Kit 1.4.

Check your knowledge with the following interaction:

Performing role based tests

Scenario tests can be specific to roles in the application for more comprehensive testing. While creating the test case, you can tag scenario tests to a specific role (such as worker or manager).

Use case: Consider a case where an agent initiates an event. However, moving the case to the next stage or taking further action on the case is done only by a manager. As a result, two roles (agent and manager) act on a single work object.

Problem statement: You need to achieve end-to-end automation for a scenario that includes approvals or multiple roles that interfere with the flow.

Solution: A scenario test case can be tagged to a specific access group while creating the test case by selecting the Role specific test checkbox. A single user with all the access groups listed on the Application access landing page (Dev Studio > Operator > Application access) can run all these test cases.

For example, consider three users with roles as Agent, Manager and Admin.

  • The first user with the role of an Agent can only initiate an event. 
  • The second user with the role of a Manager has the privilege to approve or reject the events initiated by an Agent.
  • The third user with the role of an Admin will be able to both initiate and approve or reject the events.

An agent creates a scenario test on event initiation and tags the test case to an agent specific access group. The manager creates another test case to approve the event initiated by the agent and tags the test case to a manager specific access group. The agent cannot run the test case created in the context of manager and the manager cannot run the test case that is created by the agent. The admin has both the permissions of agent and manager (that is, the access groups of both the agent and manager added to the admin's profile). As a result, the admin can run both these test cases together using the role based testing feature.

Test the entire flow by executing both test cases:

  1. Create a scenario test case.
  2. After recording, click on Stop and save test case.
  3. On the New test case form, select the Role specific test checkbox.
  4. In the AccessGroupInfo field, enter an access group that applies to the test.
  5. Click Save.

The Test cases tab on the Application: Scenario testing landing page includes a field with an access group tagged to the test. For greater convenience, you can filter test cases based on the access group.

For more information, see the Pega Test Automation kit 1.5 release notes.

Check your knowledge with the following interaction:

Reusing data captured from the UI

When you run a group of test cases together (in the same session) from a suite or during a bulk execution, you can capture values from the UI of certain tests, and then reuse them in another step of the same test case or a different test case.

Specify a unique property name to store the captured data. You can use the same property name to refer to the data in the other steps or tests, which ensures a smooth and automated testing experience.

Use case: Consider a government application with the Add household case type that consists of two stages. The first stage involves providing all household details such as dwelling type, number of persons, and address, and the second stage involves adding members to the household. 
The Add household
case type is used to register a new household. Only members who are registered through the Add person case type can be added to the household.

Problem statement: You create a test case on the Add household case type record to the second stage. However, if a specific person to add to the household is not listed, the work object stops at that point, and the system saves the test case. Later, when the person is registered through the “Add person” case type, you want to open the household work object by using the household work object ID and proceed to add members. 

Solution: By using this feature, at any step, while recording or editing a test case, capture the value into a property and refer to the property at another step or test case that runs within that session:

  1. In the header of Dev Studio, click Configure > Application > Quality > Automated testing > Scenario testing > Test cases.
  2. Open a scenario test case in which you want to capture a certain value:
    Choice Action
    Capture the value of a selected step
    1. On the Definition tab, in the Test case steps section, click the step whose value you want to capture.
    2. In the Actions section, select the Capture value of step to use at another step/test case checkbox.
    3. Enter a unique property name to store the value of that step.
    Reuse the captured value
    1. On the Definition tab, in the Test case steps section, click the step for which you want to apply the captured value.
    2. In the Actions section, in the Value type list, select Captured value.
    3. In the Value field, enter the property name that stores the captured value to reuse.
  3. In the upper-right corner, click Check out.
  4. Click Save.

When you execute these test cases in bulk or as part of a test suite, the system applies the captured values according to the configuration.

Check your knowledge with the following interaction:

Recording a custom step

This feature provides a convenient way to record any element that the scenario testing framework does not identify. With this enhancement, you can record any UI element by providing an XPath of that element. 

For example, if the test does not recognize a non-out-of-the-box element, you can use the XPath of the element to identify it uniquely and record it during test case creation.

Use case: Attempt to record a non-out-of-the-box element using a scenario testing framework.

Problem statement: The scenario testing framework relies on the data-test-ids, which are autogenerated for all the out-of-the-box Pega Platform OOTB controls. Consider a flow that you want to record as a test case; the flow contains a few mandatory fields. These mandatory fields are non-out-of-the-box controls and do not have data-test-ids. As a result, it is not possible to record the complete flow.

Solution: Using the custom step enhancement, record any custom control by specifying the XPath of the element:

  1. While recording a test case, record any custom control.
  2. In the Test steps pane of a selected step, click More > Add custom step.
  3. In the Custom Step dialog box, enter the details about the custom step, including the step description and XPath of the element.
  4. Click Submit.
  5. Continue recording the flow.
  6. Stop and save the test case when needed.

For more information, see Pega Test Automation Kit 1.6 release notes.

Check your knowledge with the following interaction:

This Topic is available in the following Module:

If you are having problems with your training, please review the Pega Academy Support FAQs.

Did you find this content helpful?

Want to help us improve this content?

We'd prefer it if you saw us at our best.

Pega Academy has detected you are using a browser which may prevent you from experiencing the site as intended. To improve your experience, please update your browser.

Close Deprecation Notice