Skip to main content
Version: 7.5.5

Autocompletion field

It is possible to find an autocompletion element by following attributes:

NameParameter(s)TypeDescription
autocompletionFielddataTestIdstringSearches for an autocompletion field by value of a Pega data-test-id attribute, same as autocompletionFieldByDataTestId
autocompletionFieldByDataTestIddataTestIdstringSearches for an autocompletion field by value of a Pega data-test-id attribute, same as autocompletionField
autocompletionFieldByIdidstringSearches for an autocompletion field by value of an id attribute
autocompletionFieldByCsscssstringSearches for an autocompletion field by a custom scc selector
autocompletionFieldByXPathxpathstringSearches for an autocompletion field by a custom xpath selector
autocompletionFieldByattributeNamestringSearches for an autocompletion field by an attribute name and value
attributeValuestring

In addition to that, each autocompletion field function provides an optional parameter container (to filter elements by sections, if required).

Main action functions

In Pega, there are two types of filtered values DOM structure:

  1. After the filtering, results are inside the autocomplete-results class.
  2. After the filtering, results are inside the ooargs or gargs type of attribute.

In the first case, main action functions are:

NameParameter(s)TypeDescription
filterfilterstring / string[]Filters the value by the passed string (minus 1 character, if the value length is >=3)
options?{ index?: number, timeout?: number, interval?: number, retries?: number }
filterCharacterByCharacterfilterstringFilters the value by the passed string with a pause after each character (intervalBetweenCharacters is configurable, default value is 1000 ms)
intervalBetweenCharacters?number
options?{ index?: number, timeout?: number, interval?: number, retries?: number }
selecttextstringSelects the value equal to the passed string (if it is available in filtered results)
options?{ timeout?: number, interval?: number, retries?: number }
selectByIndexindexnumberSelects the value by index
options?{ timeout?: number, interval?: number, retries?: number }
filterAndSelectfilterstringFilters values and selects the one equal to the passed string
text?string (value to select; if no value provided, text === filter)
options?{ timeout?: number, interval?: number, retries?: number }
openListoptions?{ timeout?: number, interval?: number, retries?: number }Opens the list with possible filtering results
closeListoptions?{ timeout?: number, interval?: number, retries?: number }Closes the list with possible filtering results

In the second case, main action functions are:

NameParameter(s)TypeDescription
filterfilterstring / string[]Filters the value by the passed string (minus 1 character, if the value length is >=3)
options?{ index?: number, timeout?: number, interval?: number, retries?: number }
filterCharacterByCharacterfilterstringFilters the value by the passed string with a pause after each character (intervalBetweenCharacters is configurable, default value is 1000 ms)
intervalBetweenCharacters?number
options?{ index?: number, timeout?: number, interval?: number, retries?: number }
selectResultFromExternalSourceplPropNamestring (plPropName attribute value)Selects the value equal to the passed string (if it is available in filtered results)
textsstring/string[]
expectedValueAfterSelection?string (if no value provided, expectedValueAfterSelection === texts)
options?{ timeout?: number, interval?: number, retries?: number }
selectResultFromExternalSourceWithRetriesplPropNamestring (plPropName attribute value)Selects the value equal to the passed string (if it is available in filtered results) and retries if the value was not selected from the first attempt
textsstring/string[]
expectedValueAfterSelection?string (if no value provided, expectedValueAfterSelection === texts)
options?{ timeout?: number, interval?: number, retries?: number }
selectResultFromExternalSourceByJsClickplPropNamestring (plPropName attribute value)Selects the value equal to the passed string (if it is available in filtered results) by performing a JavaScript code in the console
textsstring/string[]
expectedValueAfterSelection?string (if no value provided, expectedValueAfterSelection === texts)
options?{ timeout?: number, interval?: number, retries?: number }
filterAndSelectResultsFromExternalSourceplPropNamestring (plPropName attribute value)Filters values and selects the one equal to the passed string
filterValuestring/string[]
expectedValueAfterSelection?string (if no value provided, expectedValueAfterSelection === texts)
options?{ timeout?: number, interval?: number, retries?: number }
filterAndSelectResultsFromExternalSourceWithRetriesplPropNamestring (plPropName attribute value)Filters values and selects the one equal to the passed string and retries if the value was not selected from the first attempt
filterValuestring/string[]
expectedValueAfterSelection?string (if no value provided, expectedValueAfterSelection === texts)
options?{ timeout?: number, interval?: number, retries?: number }
filterAndSelectResultsFromExternalSourceByJsClickplPropNamestring (plPropName attribute value)Filters and selects the value equal to the passed string (if it is available in filtered results) by performing a JavaScript code in the console
filterValuestring/string[]
expectedValueAfterSelection?string (if no value provided, expectedValueAfterSelection === texts)
options?{ timeout?: number, interval?: number, retries?: number }
filterAndSelectResultsFromExternalSourceByJsClickWithRetriesplPropNamestring (plPropName attribute value)Filters and selects the value equal to the passed string (if it is available in filtered results) by performing a JavaScript code in the console and retries if the value was not selected from the first attempt
filterValuestring/string[]
expectedValueAfterSelection?string (if no value provided, expectedValueAfterSelection === texts)
options?{ timeout?: number, interval?: number, retries?: number }
openListoptions?{ timeout?: number, interval?: number, retries?: number }opens the list with possible filtering results
closeListoptions?{ timeout?: number, interval?: number, retries?: number }closes the list with possible filtering results

Example of the DOM structure with the second type of autocompletion field structure:

<table class="gridTable " style="width: 630px; table-layout: fixed;" cellspacing="0" cellpadding="0" id="bodyTbl_right" browresize="false" pl_prop="D_BooksList.pxResults" pl_prop_class="KE-TCF-Data-Books" prim_page="pyWorkPage" grid_ref_page="pyWorkPage">
<tbody>
<tr class="cellCont"><td title="" class="hiddenCell" pycelltype="static" style="height:0px;width:152px;visibility:hidden;height:1px;"><div class="oflowDiv" style="height:0px;"><div tabindex="0" class="divCont "><span class="wspan"></span><div class="cellIn ">Name</div></div></div></td><td title="" class="hiddenCell" pycelltype="static" style="width: 315px; visibility: hidden; height: 1px;"><div class="oflowDiv" style="height:0px;"><div tabindex="0" class="divCont "><span class="wspan"></span><div class="cellIn ">Author</div></div></div></td> </tr>
<tr class="oddRow cellCont" data-gargs="[&quot;William Shakespeare&quot;,&quot;1232&quot;,&quot;Hamlet&quot;]" oaargs="KE-TCF-Data-Books','&amp;Name=Hamlet&amp;Author=William Shakespeare" id="$PD_BooksList$ppxResults$l1" pl_index="1"><td title="" style="height:22px;" class="autocompleteAGleft gridCell" tabindex="0"><div class="oflowDiv" style="height:22px;"><div class="divCont"><span class="wspan"></span><div class="cellIn"><span>William Shakespeare</span></div></div></div></td><td title="" headers="a2" style="height:-2px;" class="gridCell"><div class="oflowDivM "><span>Hamlet</span></div></td> </tr>
<tr class="evenRow cellCont" data-gargs="[&quot;Gustav Flaubert&quot;,&quot;1850&quot;,&quot;Madame Bovary&quot;]" oaargs="KE-TCF-Data-Books','&amp;Name=Madame Bovary&amp;Author=Gustav Flaubert" id="$PD_BooksList$ppxResults$l2" pl_index="2"><td title="" style="height:22px;" class="autocompleteAGleft gridCell"><div class="oflowDiv" style="height:22px;"><div class="divCont"><span class="wspan"></span><div class="cellIn"><span>Gustav Flaubert</span></div></div></div></td><td title="" headers="a2" style="height:-2px;" class="gridCell"><div class="oflowDivM "><span>Madame Bovary</span></div></td> </tr>
<tr class="oddRow cellCont" data-gargs="[&quot;Gustav Flaubert&quot;,&quot;1850&quot;,&quot;Madame Bovary Second&quot;]" oaargs="KE-TCF-Data-Books','&amp;Name=Madame Bovary Second&amp;Author=Gustav Flaubert" id="$PD_BooksList$ppxResults$l3" pl_index="3"><td title="" style="height:22px;" class="autocompleteAGleft gridCell "><div class="oflowDiv" style="height:22px;"><div class="divCont"><span class="wspan"></span><div class="cellIn"><span>Gustav Flaubert</span></div></div></div></td><td title="" headers="a2" style="height:-2px;" class=" gridCell "><div class="oflowDivM "><span>Madame Bovary Second</span></div></td> </tr>
<tr class="evenRow cellCont" data-gargs="[&quot;Marcel Proust&quot;,&quot;1879&quot;,&quot;Search of Lost Time&quot;]" oaargs="KE-TCF-Data-Books','&amp;Name=Search of Lost Time&amp;Author=Marcel Proust" id="$PD_BooksList$ppxResults$l4" pl_index="4"><td title="" style="height:22px;" class="autocompleteAGleft gridCell cellHover"><div class="oflowDiv" style="height:22px;"><div class="divCont"><span class="wspan"></span><div class="cellIn"><span>Marcel Proust</span></div></div></div></td><td title="" headers="a2" style="height:-2px;" class="gridCell cellHover"><div class="oflowDivM "><span>Search of Lost Time</span></div></td> </tr>
</tbody>
</table>

To select a value of the autocompletion field from the example above, you need to use a pl_prop attribute (full value or partial value), e.g.:

await pega.autocompletionFieldByDataTestId(`202004070615060327134211`)
.filterAndSelectResultsFromExternalSource('D_BooksList.pxResults', 'Madame Bovary');

or

await pega.autocompletionFieldByDataTestId(`202004070615060327134211`)
.filterAndSelectResultsFromExternalSourceWithRetries('D_BooksList', 'Search of Lost Time');

There is an option to check if the selected value of an autocompletion file is equal to the expected one. By default, it is equal to the text set to be used at the selection step, but you can specify a different value if required. In the example below, the value "Madame Bovary" is selected, but the autocompletion field will show an author name, "Gustav Flaubert":

await pega.autocompletionFieldByDataTestId(`202004070615060327134211`)
.selectResultFromExternalSource('D_BooksList.pxResults', 'Madame Bovary', 'Gustav Flaubert');

If there is a need to be very precise with selection because of many very similar options after filtering, you can pass the list of strings as the value to be selected. In this case, only the option that contains ALL the parts of this list will be used for selection step. If filterAndSelectResultsFromExternalSource function was used, only the first item in the list will be applied for filtering, but all the items should be presented in the selected option:

await pega.autocompletionFieldByDataTestId(`202004070615060327134211`)
.filterAndSelectResultsFromExternalSource('D_BooksList.pxResults', ['Gustav Flaubert', 'Madame Bovary'], 'Gustav Flaubert');

Get element to select

If you need a Selector of the element you want to select after filtering, use this function:

NameParameter(s)TypeDescription
getElementToSelectplPropNamestring (plPropName attribute value)Returns selector (xpath) of the element in the results list that contains text or texts passed (in a string format)
textsstring / string[]

Assertions

Specific assertions

NameParameter(s)TypeDescription
assertResultFromExternalSourceIsVisibleplPropNamestring (plPropName attribute value)Checks if the the option with a particular string is visible after filtering
textstring
options?{ timeout?: number, assertionTimeout?: number, interval?: number, retries?: number }
assertResultFromExternalSourceIsNotVisibleplPropNamestring (plPropName attribute value)Checks if the the option with a particular string is no visible after filtering
textstring
options?{ timeout?: number, assertionTimeout?: number, interval?: number, retries?: number }
assertResultWithComponentsIsVisibleplPropNamestring (plPropName attribute value)Checks if the the option with particular strings is visible after filtering
textsstring[]
options?{ timeout?: number, assertionTimeout?: number, interval?: number, retries?: number }
assertResultWithComponentsIsNotVisibleplPropNamestring (plPropName attribute value)Checks if the the option with particular strings is not visible after filtering
textsstring[]
options?{ timeout?: number, assertionTimeout?: number, interval?: number, retries?: number }
shouldHaveSizeOfResultsFromExternalSourceplPropNamestring (plPropName attribute value)Checks if the the size of the results collection is equal to a passed number (option 2 of autocomplete results selection)
sizenumber
options?{ timeout?: number, assertionTimeout?: number, interval?: number, retries?: number }
shouldHaveSizeOfResultsListsizenumberChecks if the the size of the results collection is equal to a passed number (option 1 of autocomplete results selection)
options?{ timeout?: number, assertionTimeout?: number, interval?: number, retries?: number }

Common assertions

NameParameter(s)TypeDescription
shouldBeVisibleoptions?{ index?: number, timeout?: number, assertionTimeout?: number, interval?: number, retries?: number }Checks if the element exists and is visible
shouldExistoptions?{ index?: number, timeout?: number, assertionTimeout?: number, interval?: number, retries?: number }Checks if the element exists
shouldNotBeVisibleoptions?{ index?: number, timeout?: number, assertionTimeout?: number, interval?: number, retries?: number }Checks if the element exists but is not visible
shouldNotExistoptions?{ index?: number, timeout?: number, assertionTimeout?: 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 }
shouldHaveValuevaluestringChecks if the element's value contains a given string
options?{ index?: number, timeout?: number, assertionTimeout?: number, interval?: number, retries?: number }
shouldNotHaveValuevaluestringChecks if the element's value does not contain 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
shouldBeRequiredoptions?{ timeout?: number, assertionTimeout?: number, interval?: number, retries?: number }Checks if the field is mandatory
shouldNotBeRequiredoptions?{ timeout?: number, assertionTimeout?: number, interval?: number, retries?: number }Checks if the field is not mandatory
shouldHaveValidationTypevalidationTypestringChecks if the element's validation type is equal to a given one
options?{ timeout?: number, assertionTimeout?: number, interval?: number, retries?: number }
shouldNotHaveValidationTypevalidationTypestringChecks if the element's validation type is not equal to a given one
options?{ timeout?: number, assertionTimeout?: number, interval?: number, retries?: number }

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.autocompletionFieldByDataTestId(`202004070615060327134211`)
.waitForSelectActionabilityCheck(['attached', 'visible', 'stable']);

Other helpers

NameParameter(s)TypeDescription
focusoptions?{ timeout?: number, interval?: number, retries?: number }Focuses the element. A focused element is ready to be activated with a keyboard or any keyboard-emulating technology
pressTabSimulates "press Tab key" action
clickoptions?{ timeout?: number, interval?: number, retries?: number }Clicks in the field

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

GetValue and GetText functions

NameParameter(s)TypeDescription
getValueReturns element's value as a string
getTextReturns element's inner text as a string