Using has_text with non-English characters

Viewed 67

I'm trying to click a link on a page using Playwright for Python that has non-English characters in its text:

page.locator("a", has_text="Grégoire").click()

hangs and gives the error:

waiting for selector "a >> :scope:has-text("Gr\u00e9goire")"

Note that this code works for links with English names on the same page. How do you use has_text with non-English characters?

1 Answers

Use :has-text text selector:

page.locator('a:has-text("Grégoire")').click()
Related