microsoft / microsoft/playwright-java
[Feature]: Numerical Comparison Assertions for hasCount
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Java
- Sterne
- 1.6k
- Forks
- 298
- Ø Merge
- 3 T. 2 Std.
- Gemergte PRs (30 T.)
- 14
Beschreibung
🚀 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.
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne damit, die vorhandene Implementierung der hasCount-Assertion und die von Playwright verwendete Polling-Infrastruktur zum Abrufen von Elementanzahlen zu lokalisieren. Prüfe, wie vergleichbare Assertions Bedingungen für größer als, kleiner als, mindestens und höchstens bereitstellen. Als erledigt gilt die Unterstützung von Schwellenwertprüfungen durch die vorgeschlagenen Methoden mit nativem Polling sowie eine bessere Lesbarkeit gegenüber negierten Gleichheitsprüfungen.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- java
- Bereich
- testing
- Issue-Typ
- Feature
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 48/100