-
Notifications
You must be signed in to change notification settings - Fork 259
Description
🚀 Feature Request
Currently, assertThat(locator).hasCount(n) only supports strict equality. In many real-world testing scenarios, the exact number of elements is dynamic, and we only need to verify if the count meets a certain threshold (e.g., "at least one item is present" or "no more than 10 items").
Example
Proposed Methods: hasCountGreaterThan(int n), hasCountLessThan(int n), hasCountAtLeast(int n), hasCountAtMost(int n).
Motivation
Improved Readability: Replaces less intuitive workarounds like assertThat(locator).not().hasCount(0).
Native Polling: These checks would leverage Playwright’s built-in auto-waiting mechanism, making tests much more stable than manual polling loops.
Implementation: The implementation is straightforward as Playwright already has the infrastructure to retrieve element counts and poll for conditions. It simply requires adding comparison operators to the assertion logic.