web » assertElementCount(locator,count)
Description
This command is to assert the count of element as per defined locator.
This command will find element count through locator and match with expected count specified via count
and pass or fail accordingly.
The expected count can be specified as Number
or Nexial Filters
. Specify filter on
count
parameter in following way.
Count Filter
This command supports filters
to assert count parameter in special way. count filter
can be expressed as
Nexial Filter to create single criteria filter on element count.
But in this special case, Nexial user don’t need to provide [subject]
for Nexial Filter.
Nexial will automatically pick actual element count as [subject]
for Nexial Filter
during evaluation itself.
For example, if count parameter is given as = 4
, then it will be evaluated as ${actualCount} = 4
during Nexial execution.
count parameter | description |
---|---|
= ${expectedCount} | Is actual element count equals to expected count? |
>= 5 | Is actual element count greater than or equals to 5? |
in [2|3|5|9] | Is actual element count one of the items in the list |
between [2|9] | Is actual element count between 2 and 9? |
Note- Multiple criteria filter is currently restricted to use in this assertion.
Parameters
- locator - this parameter is to find the locator of the element.
- count - this parameter is the expected element count which can specified as
number
orNexial filter
.
Example
-
Parameter
count
specified as number
Script:
Output:
-
Parameter
count
specified as Nexial Filter
Script:
Output: