← Back to Discord Forum

Checking elements with custom properties

Any insights on how to check if an icon with custom property exist in the page? Example mat icon with custom tag and value

This thread is trying to answer question "How to check if an icon with a custom property exists on a page?"

2 replies

Do you want to check on a specific icon element that you can write a locator for? In that case you can use https://playwright.dev/docs/api/class-locatorassertions#locator-assertions-to-have-attribute

If you want to know if there is any at all you would have a special locator for it, something like page.locator("mat-icon[tag='value']") . And check if it is attached or visible.

Idk if it would work to use the locator like this, but I think I would prefer writing it like this: page.locator('mat-icon').locator('tag=value')

Thanks yeah I want to check if the icon with given tag= icon name exist. Will give it a try

Related Discord Threads

AboutQuestionsDiscord ForumBrowser ExtensionTagsQA Jobs

Rayrun is a community for QA engineers. I am constantly looking for new ways to add value to people learning Playwright and other browser automation frameworks. If you have feedback, email luc@ray.run.