Automated e2e testing with Pega Selenium Starter Kit
This article is part of Test Automation series
Introduction
Selenium Starter Kit is a Selenium-based UI test framework and sample UI tests for testing your Pega application. The starter kit comes with a framework that you can use for creating UI based E2E automated testing.
For full reference please visit Selenium Starter Kit | Pega
In this article we will use the “sample test framework” package for demonstrating the ease of creating a proof of concept for automated UI testing of Constellation applications. To be clear, SSK can be used on any web application including UIKit or Cosmos.
Why Selenium Starter Kit, and why not ?
The framework is based on solid industry standards ( Selenium, Cucumber, TestNG ) that cuts out a lot of work. There are similar frameworks publically available, having same setup, but SSK adds a layer for interacting with Pega UI elements specifically.
It comes with a great documentation : a detailed setup guide, how to write and run test locally or through DevOps and finally developer’s guide to extend the framework.
It includes sample UI test framework to support testing core Pega CRM applications – Pega Sales Automation, Pega Customer Services and Customer Decision Hub (formerly Pega Marketing).
Contains an extendable model for defining Pega components like ”Portal” and ”Work” with the related actions to reuse across test cases. Login and logoff actions, interacting with autocomplete and other OOTB actions are available in SSK.
This approach matches perfectly the concept of prescribed design system carried by Constellation in which pre-designed components are customized. It is possible to use SSK for modeling the test automation assets of every OOTB Constellation component.
There are some known drawbacks using Selenium which may influence the choice and use of SSK for long-term test automation initiative:
- With Selenium it is not easy to record the scenarios, debug and playback
Test Engineers with Selenium expertise can be involved to upskill QA team - It requires a Selenium Grid for execute the test cases in CI/CD
If the client does not worth to invest in services like BrowserStack
then a custom Selenium Grid, shared between organization, is easy to setup and maintain
Creating a proof of concept with SSK
If your client starts from the ground and wants a bite of test automation SSK is perfect for building a proof of concept and, in long term, evolve into a test automation asset for Pega applications.
Create a proof of concept for automated e2e testing with SSK is an easy process that can be synthetized in 5 points :
- Identify the scenario/s to automate
- Obtain a cucumber feature of it
- Collect all the related locators
- Setup Pega for test automation
- Create test users for the above scenario
- Setup test automation project
- Install SSK by following the instructions
- Configure SSK with URL and credentials
- Create and refine the script
- Generate stub java code from cucumber feature
- Implement each step with collected locators
The above steps should be taken for any attempt of POC regardless of the runtime language or UI technology used. SSK allows shortcuts to the effort of setting up an automation project using Java and Selenium.
Identify the scenario/s to automate
For a while the scenario should not be very complex but not limited to just login either.
Ideally you should pick a scenario that includes :
- A creation form of minimum 2-3 steps to demonstrate the fulfillment of data
with different techniques (single value, example, table data ) - An approval step or similar for demonstrate role-base testing
- Some assertions related to case status or routing to validate the scenario
In this example the scenario is “service related incident” which belongs to application TellUsMore. The e2e process spans over two different portals and three different personas: Customer, Dispatcher and Case Worker.
Obtain a cucumber feature
Writing a cucumber feature properly is not immediate so, if you don’t have the skill then you can ask business architects, QA team, or eventually AI.
Below the image shows how the steps of an E2E can be expressed as elements in the cucumber features and how those elements are related to Pega application objects.
This feature will produce 3 test cases at runtime : one for each of the IncidentSubType ”Examples” at the bottom.
Notice that the assignments here are basically a collection of test data :
I select "Customer service issue" as the Incident Type - Use this to fulfil a single value
I select "<IncidentSubType>" as the Incident SubType - Use corner brackets to fulfill a single values by example
I select incident type "Product faulty or unsafe" with subtype "Product not as described" - Use this to fulfil two values
When the field number grows then is better use the table data approach as below
And I fill in the service details: | What happened? | Service representative was rude | | Where did it happen? | Phone call | | When did it happen? | 2025-01-23 | | Channel | Phone |
Collect all the related locators
If the target application has properly defined the TestID attribute of every UI element then should be easy to derive the XPath locators for them.
In any case Selenium offers a recording/edit/playback experience with Selenium IDE which is a plugin for any browser.
|
Reusable Locators During this phase you’ll find locators which can be reused, e.g. the OOTB buttons for screen flow “Next, Previous, Cancel”. //button[@data-testid=':assignment-action-buttons:submit'] //button[@data-testid=':assignment-action-buttons:back'] //button[@data-testid=':assignment-action-buttons:cancel'] |
Setup Pega for test automation
It is necessary to create test users dedicated for UI automation for each of the roles involved and add the role PegaRules:TestID to the access group.
Setup test automation project
Install SSK by following the instructions
Find the “Setup Guide” under Selenium Starter Kit | Pega and follow it. At the end you should have the sample project set up and running.
Configure SSK with URL and credentials
Open the users.properties under data folder and set the credentials of the test operators.
Open the global-settings.properties under data folder and set the URL of your target pega application.
Other nice configurations you can do in global-settings :
browser.name=chrome let the script be run by the specific browser engine debug.mode=false let the browser open at the end of test for letting developer verify and fix the failures enable.fullscreen.mode=false let the browser open into full screen mode global.timeout=30000 let the script have a timeout for every action taken
Create the new script
Generate stub java code from cucumber feature
Copy your cucumber feature into /src/test/resources/features, set the same tag into pom.xml then run the project.
The console will show an error message for “unimplemented steps”
io.cucumber.testng.UndefinedStepException: The step 'I should see the incident creation form' and 7 other step(s) are undefined. You can implement these steps using the snippet(s) below: @When("I select {string} as the Incident Type") public void i_select_as_the_incident_type(String string) { // Write code here that turns the phrase above into concrete actions throw new io.cucumber.java.PendingException(); } @When("I select {string} as the Incident SubType") public void i_select_as_the_incident_sub_type(String string) { // Write code here that turns the phrase above into concrete actions throw new io.cucumber.java.PendingException(); }
Implement each step with collected locators
To implement the steps create a new class under src/test/java/stepdefs, for example IncidentStepDefs.java and paste the stub methods obtained in the last run.
Define the locators for the elements :
Fullfill the methods with proper actions
@When("I select {string} as the Incident Type") public void i_select_as_the_incident_type(String string) { pegaDriver.findSelectBox(INCIDENT_TYPE).selectByValue(string); } @When("I select {string} as the Incident SubType") public void i_select_as_the_incident_sub_type(String string) { pegaDriver.findSelectBox(INCIDENT_SUBTYPE).selectByValue(string); }
Sample implementation withTellUsMore application
If you want to experience a working example there is one. Take a look on this GitHub project and follow the readme for usage.
|
This sample contains the implementation of POC on TellUsMore application :
PlatformBrowser.java : contains implementation for “Given I am logged into the customer portal”
SelfServicePortal.java : contains implementation for “When I click on Incident tile”
IncidentStepDefs.java : contains implementations of the other steps
create-service-related-inc.feature : is the feature file with scenario(s)
|
Download and import TellUsMore on your sandbox / local / labs and use as target.
TellUsMoreRef_TestAutomation_20250416T110302.032 GMT.zip
Final Result
Conclusion
This guide provides a foundation for testing Constellation applications using Selenium Starter Kit. Because SSK is a Pega test automation tool and is based on a solid framework it is perfect for proof of concepts around automated e2e testing on Constellation applications when Java is the target runtime.