Function: getListItemCount()
getListItemCount<
HostPartT>(host,itemLocatorBase):Promise<number>
Defined in: packages/core/src/drivers/listHelper.ts:84
Count the items in a list in a single interactor round-trip, without instantiating any item driver.
Counts by locator match: Interactor.getElementCount asks the interactor
how many elements itemLocatorBase matches. This replaces the former
index-by-index exists() probing — O(n) round-trips, costly under Playwright
where locator.count() is one call — and simultaneously fixes the count-side
:nth-of-type miscount: counting by match (not by tag position) no longer
mis-sizes a list interleaved with a same-tag non-item (a header/divider <li>).
Homogeneous-siblings requirement. getListItemByIndex still ADDRESSES
the i-th item by appending :nth-of-type(i + 1) to itemLocatorBase, so this
count and that index access agree only when the items are the homogeneous set
the base matches — i.e. no non-item sibling of the same tag shifts the
:nth-of-type reckoning. For lists that mix item tags or interleave same-tag
non-items, use childListHelper's countMatchingChildren /
iterateMatchingChildren instead, whose :nth-child + childSelector
filter tolerates mixed siblings.
Type Parameters​
HostPartT​
HostPartT extends ScenePart
Parameters​
host​
ComponentDriver<HostPartT>
The component the list items are under
itemLocatorBase​
The locator of the list items without the index; it must match the homogeneous item set only (see the requirement above)
Returns​
Promise<number>
The number of items in the list