Closed dajunhuo closed 2 years ago
#nav-bar:text("Home")
and #nav-bar :text("Home")
are two different selectors with different semantics. First is looking for an element nav-bar that has given text, another is looking for nested elements inside navbar that have text.
You would typically say #nav-bar:hasText("Home")
instead, or better yet page.locator('#nav-bar', { hasText: 'Home' })
.
Context:
Code Snippet
Describe the bug
The documentation for text selectors as seen in the URL https://playwright.dev/dotnet/docs/selectors#text-selector only worked for me if I remove the space between the element and the colon e.g.
Here's an example of what I was trying to select (with text censored)