Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature]: Add ToMatchSelectorAsync to LocatorAssertion #33978

Open
Totati opened this issue Dec 12, 2024 · 1 comment
Open

[Feature]: Add ToMatchSelectorAsync to LocatorAssertion #33978

Totati opened this issue Dec 12, 2024 · 1 comment

Comments

@Totati
Copy link

Totati commented Dec 12, 2024

🚀 Feature Request

Add a LocatorAssertion, so the element can be checked against matching a css selector. This would allow more robust assertions.
HTMLElement implements a matches method, this allows checking attributes, classes with one call. Same would be nice in Playwright as well.

Example

<div class='selected row' id='component'></div>
var locator = Page.Locator("#component");
await Expect(locator).ToMatchSelectorAsync('.selected');

Motivation

Using Regex and ToHaveClassAsync and checking attributes one by one with ToHaveAttributeAsync feels inefficient.

@mxschmitt mxschmitt transferred this issue from microsoft/playwright-dotnet Dec 12, 2024
@yury-s
Copy link
Member

yury-s commented Dec 12, 2024

Is there another example apart from matching multiple classes on the same element where it would be useful?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants