I would like to have waitForElementText() in playwright.
E.g I have headers on each page cssSelector = '.header-name'.
and I navigate from Home page to Users
I pass two arguments to the method: waitForElementText( locator: string, expectedText: string)
and I want to wait for the header name to change from Home → Users
I tried to use page.waitForFunction() method but I get error:
page.waitForFunction: TypeError: Cannot read properties of undefined (reading 'locator')
Since Playwright's locator's API waits for elements automatically and has a text-based selector,
waitForTextis already in the API asgetByText:You can chain locators if this isn't enough to disambiguate the element: