microsoft / playwright

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
https://playwright.dev
Apache License 2.0
67.15k stars 3.69k forks source link

[Feature] locator to handle negation conditions #14136

Open joshuaManlunas opened 2 years ago

joshuaManlunas commented 2 years ago

Use case: Allow Playwright Locator to choose all elements that does NOT have a text or NOT have a class or NOT have the attribute.

Examples: Current state: locator.locator("css=bx-card-row:not(:has(span.blocked_badge))", {hasText: "Visa Debit Card"}) (Hard to read)

Preferred way: locator.locator("bx-card-row", {hasText: "Visa Debit Card"}).not("text=Blocked") (Easy to read)

CeamKrier commented 2 years ago

Hey!

Any update on this?

dgozman commented 1 year ago

22066 will introduce Locator.not() in the next release.

schrufygroovy commented 1 year ago

Can someone reopen this issue since the Locator.not() did not make it due to https://github.com/microsoft/playwright/pull/22223 ?

The Locator.not() would really be handy, when one has to do Difference of Two Sets (set theory)

mrobinson-campion commented 9 months ago

I would find this really handy too thanks!

ruifigueira commented 3 weeks ago

Having already Locator.and implemented with the internal:and engine, it seems that a similar implementation for a internal.not should be trivial. Is there any chance of marking this issue with open-to-a-pull-request?