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).
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:
Name | Parameter(s) | Type | Description |
---|---|---|---|
button | Creates a new instance of a FormButton class (please find description below) | ||
button.byText | value | string | Searches for a button element by its inner text |
buttonByDataTestId | dataTestId | string | Searches for a button element by value of a Pega data-test-id attribute |
buttonById | id | string | Searches for a button element by value of an id attribute |
buttonByTitle | title | string | Searches for a button element by value of a title attribute |
In many cases, button's inner text and value of 'title' attribute are not equal
Main action functions
Name | Parameter(s) | Type | Checkbox type | Description |
---|---|---|---|---|
hover | options? | { timeout?: number, interval?: number, retries?: number } | box type | Hovers over the element |
click | options? | { timeout?: number, interval?: number, retries?: number } | box type | Clicks the element (left click) |
rightClick | options? | { timeout?: number, interval?: number, retries?: number } | slider type | Right clicks the element |
middleClick | options? | { timeout?: number, interval?: number, retries?: number } | box type | Middle clicks the element |
doubleClick | options? | { timeout?: number, interval?: number, retries?: number } | box type | Double clicks the element |
hoverAndClick | options? | { timeout?: number, interval?: number, retries?: number } | slider type | Hovers the element then clicks (right click) |
Common assertions
Name | Parameter(s) | Type | Description |
---|---|---|---|
shouldBeVisible | options? | { timeout?: number, interval?: number, retries?: number } | Checks if the element exists and visible |
shouldExist | options? | { timeout?: number, interval?: number, retries?: number } | Checks if the element exists |
shouldNotBeVisible | options? | { timeout?: number, interval?: number, retries?: number } | Checks if the element exists but is not visible |
shouldNotExist | options? | { timeout?: number, interval?: number, retries?: number } | Checks if the element does not exist |
shouldHaveText | value | string | Checks if the element's inner text contains a given string |
options? | { index?: number, timeout?: number, assertionTimeout?: number, interval?: number, retries?: number } | ||
shouldNotHaveText | value | string | Checks if the element's inner text does not contain a given string |
options? | { index?: number, timeout?: number, assertionTimeout?: number, interval?: number, retries?: number } | ||
shouldHaveExactText | value | string | Checks if the element's inner text is equal to a given string |
options? | { index?: number, timeout?: number, assertionTimeout?: number, interval?: number, retries?: number } | ||
shouldNotHaveExactText | value | string | Checks if the element's inner text is not equal to a given string |
options? | { index?: number, timeout?: number, assertionTimeout?: number, interval?: number, retries?: number } | ||
shouldBeEnabled | options? | { index?: number, timeout?: number, assertionTimeout?: number, interval?: number, retries?: number } | Checks if the element doesn't have a disabled attribute |
shouldBeDisabled | options? | { 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
Name | Parameter(s) | Type | Description |
---|---|---|---|
waitUntilVisibility | options? | { timeout?: number, interval?: number, retries?: number } | Waits for the element to be visible |
waitUntilInvisibility | options? | { timeout?: number, interval?: number, retries?: number } | Waits for the element to be invisible |
waitUntilElementExists | options? | { timeout?: number, interval?: number, retries?: number } | Waits for the element to exist |
waitUntilElementNotExist | options? | { 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:
Name | Parameter(s) | Type | Description |
---|---|---|---|
waitUntilVisibilityByText | text | string | Filters collection of elements by text and waits for the element to be visible |
options? | { timeout?: number, interval?: number, retries?: number } | ||
waitUntilVisibilityByAttribute | attributeName | string | Filters collection of elements by attribute and waits for the element to be visible |
attributeValue | string | ||
options? | { timeout?: number, interval?: number, retries?: number } | ||
waitUntilVisibilityByIndex | index | number | Filters collection of elements by index and waits for the element to be visible |
options? | { timeout?: number, interval?: number, retries?: number } | ||
waitUntilInvisibilityByIndex | index | number | Filters 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
Name | Parameter(s) | Type | Description |
---|---|---|---|
waitUntilCollectionOfElementsSizeIsGreaterOrEqual | expectedSize | number | Waits until collection of elements have specific size (or there are more) |
options? | { timeout?: number, interval?: number, retries?: number } | ||
waitUntilCollectionOfElementsSizeIsLessThan | expectedSize | number | Waits until collection of elements have fewer elements than specified |
options? | { timeout?: number, interval?: number, retries?: number } |
Actionability check
ActionabilityCheckTypes == attached
| stable
| visible
| enabled
| editable
Name | Parameter(s) | Type | Description |
---|---|---|---|
waitForSelectActionabilityCheck | check types | [] | Waits for the element to pass all the selected actionability check types |
isFilterByVisibility | boolean (true by default) |
e.g.
await pega.buttonByDataTestId('Submit').waitForSelectActionabilityCheck(['attached', 'visible', 'stable']);
IsVisible and IsExists functions
Name | Parameter(s) | Type | Description |
---|---|---|---|
isVisible | options? | { timeout?: number, interval?: number, retries?: number } | Returns true if the element exists and is visible |
isExists | options? | { 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:
Name | Parameter(s) | Type | Description |
---|---|---|---|
save | Clicks save button | ||
submit | Clicks submit button | ||
submitPopUp | Clicks submit button in pop-ups (with [id="ModalButtonSubmit"]) | ||
byText | value | string | Clicks the button with an inner text equal to a given string |
Main actions:
Name | Parameter(s) | Type | Description |
---|---|---|---|
click | options? | { timeout?: number, interval?: number, retries?: number } | Clicks the element (left click) |
shouldBeVisible | options? | {timeout?: number, assertionTimeout?: number, interval?: number, retries?: number } | Checks if the element exists and visible |
shouldNotBeVisible | options? | {timeout?: number, assertionTimeout?: number, interval?: number, retries?: number } | Checks if the element exists but is not visible |
E.g.:
await pega.button.submit().click();
Form Buttons were created to make test implementation faster and could be easily replaced by usual Button methods if required.