Louis and the cat
Louis and the cat

Reputation: 11

Test for text on a page

Very basic question but I can't figure it out.

How do I test for the existence of a piece of text on a page?

e.g. does the word "mouse" exist on this page? I'm using playwright and node.js

Thanks!

Upvotes: 0

Views: 64

Answers (1)

Max Schmitt
Max Schmitt

Reputation: 3152

You can do that via page.waitForSelector(). Example:

await page.waitForSelector('text=mouse')

See on playwright.dev for the full documentation and how you can use the text selectors in other scenarios.

Upvotes: 1

Related Questions