Skip to main content
Version: 8.0.2

Dropdown Field

While selecting a dropdown option, there is no need to open the list of values (like we are doing it manually). The value can be selected via select command, and you should be able to see the value being changed in the field.

It is possible to find a dropdown element by following attributes:

NameParameter(s)TypeDescription
dropdowndataTestIdstringSearches for a dropdown by value of a Pega data-test-id attribute, same as dropdownByDataTestId
dropdownByDataTestIddataTestIdstringSearches for a dropdown by value of a Pega data-test-id attribute, same as dropdown
dropdownByIdidstringSearches for a dropdown by value of an id attribute
dropdownByCsscssstringSearches for a dropdown by a custom scc selector
dropdownByXPathxpathstringSearches for a dropdown by a custom xpath selector
dropdownByattributeNamestringSearches for a dropdown by an attribute name and value
attributeValuestring

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

Main action functions

NameParameter(s)TypeDescription
selectvaluestring, {}?Selects the value (by the value of an value attribute). It is possible to select the element by index (in options parameter)
options?{ index?: number, timeout?: number, interval?: number, retries?: number }
selectAndCheckTheValuevaluestringSelects the value (by the value of an value attribute) and checks if an option contains selected attribute
options?{ index?: number, timeout?: number, interval?: number, retries?: number }

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 }
shouldHaveSelectedItemvaluestringChecks if the element's value contains a given string
options?{ timeout?: number, assertionTimeout?: number, interval?: number, retries?: number }
shouldNotHaveSelectedItemvaluestringChecks if the element's value does not contain a given string
options?{ timeout?: number, assertionTimeout?: number, interval?: number, retries?: number }
shouldHaveAttributeSelectedvaluestringChecks if the element's option has a selected attribute
options?{ timeout?: number, assertionTimeout?: number, interval?: number, retries?: number }
shouldNotHaveAttributeSelectedvaluestringChecks if the element's option does not have a selected attribute
options?{ timeout?: number, assertionTimeout?: number, interval?: number, retries?: number }
shouldHaveSuggestedItemsvaluesstring[]Checks if the element's options contain the list of values (as values of the value attribute); order is not considered
options?{ timeout?: number, assertionTimeout?: number, interval?: number, retries?: number }
shouldNotHaveSuggestedItemsvaluesstring[]Checks if the element's options does not contain the list of values (as values of the value attribute)
options?{ timeout?: number, assertionTimeout?: number, interval?: number, retries?: number }
shouldOnlyHaveSuggestedItemsvaluesstring[]Checks if the element's options contain only the list of values (as values of the value attribute); order is not considered
options?{ timeout?: number, assertionTimeout?: number, interval?: number, retries?: number }
shouldHaveSuggestedItemsByInnerTextvaluesstring[]Checks if the element's options contain the list of values (as inner text); order is not considered
options?{ timeout?: number, assertionTimeout?: number, interval?: number, retries?: number }
shouldNotHaveSuggestedItemsByInnerTextvaluesstring[]Checks if the element's options do not contain the list of values (as inner text)
shouldHaveInnerTextPerOptionValueoptionValuestringChecks if the element's option contain a particular combination of value of the value attribute and inner text
innerTextstring
options?{ timeout?: number, assertionTimeout?: number, interval?: number, retries?: number }
shouldNotHaveInnerTextPerOptionValueoptionValuestringChecks if the element's option does not contain a particular combination of value of the value attribute and inner text
innerTextstring
options?{ timeout?: number, assertionTimeout?: number, interval?: number, retries?: number }
shouldHaveInnerTextsPerOptionValuesoptionValuesstring[]Checks if the element's option list contain a particular combination of values of the value attribute and inner texts
innerTextsstring[]
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

Allow 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.dropdown('branch').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
hoveroptions?{ timeout?: number, interval?: number, retries?: number }Hovers over the element. A hovered element is ready to be activated with a mouse or any mouse-emulating technology
pressTabSimulates "press Tab key" action
clickoptions?{ timeout?: number, interval?: number, retries?: number }Clicks in the field

Boolean 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
isSelectedoptions?{ timeout?: number, interval?: number, retries?: number }Returns true if a dropdown option has a selected attribute

GetValue and GetText functions

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

Check a Key-Value Pair section for a better user experience with Dropdown fields.