Skip to main content
Version: 8.0.2

Buttons

In Pega, buttons are used widely. It can be a standard form button (save, cancel, submit, approve, reject), or a custom button created by developers.

Usually, a standard click() works well, but if the cursor icon changes its view an additional hover() action might be needed (even though click() includes hover, a small pause between hover and click might be very helpful. Then it's possible to use 2 methods or hoverAndClick() step).

info

An Actions button is a specific Pega widget, and for the Action button menu we've created a dedicated widget

Possible options to select a button control:

NameParameter(s)TypeDescription
buttonCreates a new instance of a FormButton class (please find description below)
button.byTextvaluestringSearches for a button element by its inner text
buttonByDataTestIddataTestIdstringSearches for a button element by value of a Pega data-test-id attribute
buttonByIdidstringSearches for a button element by value of an id attribute
buttonByTitletitlestringSearches for a button element by value of a title attribute
caution

In many cases, button's inner text and value of 'title' attribute are not equal

Main action functions

NameParameter(s)TypeCheckbox typeDescription
hoveroptions?{ timeout?: number, interval?: number, retries?: number }box typeHovers over the element
clickoptions?{ timeout?: number, interval?: number, retries?: number }box typeClicks the element (left click)
rightClickoptions?{ timeout?: number, interval?: number, retries?: number }slider typeRight clicks the element
middleClickoptions?{ timeout?: number, interval?: number, retries?: number }box typeMiddle clicks the element
doubleClickoptions?{ timeout?: number, interval?: number, retries?: number }box typeDouble clicks the element
hoverAndClickoptions?{ timeout?: number, interval?: number, retries?: number }slider typeHovers the element then clicks (right click)

Common assertions

NameParameter(s)TypeDescription
shouldBeVisibleoptions?{ timeout?: number, interval?: number, retries?: number }Checks if the element exists and visible
shouldExistoptions?{ timeout?: number, interval?: number, retries?: number }Checks if the element exists
shouldNotBeVisibleoptions?{ timeout?: number, interval?: number, retries?: number }Checks if the element exists but is not visible
shouldNotExistoptions?{ timeout?: number, interval?: number, retries?: number }Checks if the element does not exist
shouldHaveTextvaluestringChecks if the element's inner text contains a given string
options?{ index?: number, timeout?: number, assertionTimeout?: number, interval?: number, retries?: number }
shouldNotHaveTextvaluestringChecks if the element's inner text does not contain a given string
options?{ index?: number, timeout?: number, assertionTimeout?: number, interval?: number, retries?: number }
shouldHaveExactTextvaluestringChecks if the element's inner text is equal to a given string
options?{ index?: number, timeout?: number, assertionTimeout?: number, interval?: number, retries?: number }
shouldNotHaveExactTextvaluestringChecks if the element's inner text is not equal to a given string
options?{ index?: number, timeout?: number, assertionTimeout?: number, interval?: number, retries?: number }
shouldBeEnabledoptions?{ index?: number, timeout?: number, assertionTimeout?: number, interval?: number, retries?: number }Checks if the element doesn't have a disabled attribute
shouldBeDisabledoptions?{ index?: number, timeout?: number, assertionTimeout?: number, interval?: number, retries?: number }Checks if the element has a disabled attribute

Wait for functions

Simple wait for visibility functions

NameParameter(s)TypeDescription
waitUntilVisibilityoptions?{ timeout?: number, interval?: number, retries?: number }Waits for the element to be visible
waitUntilInvisibilityoptions?{ timeout?: number, interval?: number, retries?: number }Waits for the element to be invisible
waitUntilElementExistsoptions?{ timeout?: number, interval?: number, retries?: number }Waits for the element to exist
waitUntilElementNotExistoptions?{ timeout?: number, interval?: number, retries?: number }Waits for the element not to exist

Complex wait for visibility functions

Allows filtering of available elements by index, text, attribute:

NameParameter(s)TypeDescription
waitUntilVisibilityByTexttextstringFilters collection of elements by text and waits for the element to be visible
options?{ timeout?: number, interval?: number, retries?: number }
waitUntilVisibilityByAttributeattributeNamestringFilters collection of elements by attribute and waits for the element to be visible
attributeValuestring
options?{ timeout?: number, interval?: number, retries?: number }
waitUntilVisibilityByIndexindexnumberFilters collection of elements by index and waits for the element to be visible
options?{ timeout?: number, interval?: number, retries?: number }
waitUntilInvisibilityByIndexindexnumberFilters collection of elements by index and waits for the element not to be visible
options?{ timeout?: number, interval?: number, retries?: number }

Wait for a collection size functions

NameParameter(s)TypeDescription
waitUntilCollectionOfElementsSizeIsGreaterOrEqualexpectedSizenumberWaits until collection of elements have specific size (or there are more)
options?{ timeout?: number, interval?: number, retries?: number }
waitUntilCollectionOfElementsSizeIsLessThanexpectedSizenumberWaits until collection of elements have fewer elements than specified
options?{ timeout?: number, interval?: number, retries?: number }

Actionability check

ActionabilityCheckTypes == attached | stable | visible | enabled | editable

NameParameter(s)TypeDescription
waitForSelectActionabilityCheckcheck types[]Waits for the element to pass all the selected actionability check types
isFilterByVisibilityboolean (true by default)

e.g.

await pega.buttonByDataTestId('Submit').waitForSelectActionabilityCheck(['attached', 'visible', 'stable']);

IsVisible and IsExists functions

NameParameter(s)TypeDescription
isVisibleoptions?{ timeout?: number, interval?: number, retries?: number }Returns true if the element exists and is visible
isExistsoptions?{ timeout?: number, interval?: number, retries?: number }Returns true if the element exists

Form Buttons

Form Buttons are some standard Pega OOTB buttons (save, submit, etc.). For some of them there are predefined methods that allow faster implementation.

Predefined Form Buttons:

NameParameter(s)TypeDescription
saveClicks save button
submitClicks submit button
submitPopUpClicks submit button in pop-ups (with [id="ModalButtonSubmit"])
byTextvaluestringClicks the button with an inner text equal to a given string

Main actions:

NameParameter(s)TypeDescription
clickoptions?{ timeout?: number, interval?: number, retries?: number }Clicks the element (left click)
shouldBeVisibleoptions?{timeout?: number, assertionTimeout?: number, interval?: number, retries?: number }Checks if the element exists and visible
shouldNotBeVisibleoptions?{timeout?: number, assertionTimeout?: number, interval?: number, retries?: number }Checks if the element exists but is not visible

E.g.:

await pega.button.submit().click();
info

Form Buttons were created to make test implementation faster and could be easily replaced by usual Button methods if required.