I am working on my first test automation project using Playwright for .NET. For one of the tests I need to check for a specific bit of text on a page. I have been able to do a number of other tests but I can’t seem to figure this one out. The JavaScript implementation includes "has-text" but I don’t see that for .NET.
I used page.Locator("my text") but I don’t know how to check if "my text" in fact exists on the page.
3
Answers
This works:
You could do something like this:
You can use ToContainTextAsync:
So just pick the locator in which you want to check. And if you want to check for visibility you could use the
UseInnerText
option.