0

I am trying to understand how the react selectors are working according to https://playwright.dev/docs/selectors#react-selectors . So I am trying some things in playwright sandbox. Seems that the react component cannot be found.

from playwright.sync_api import sync_playwright

with sync_playwright() as p:
    browser = p.chromium.launch()
    page = browser.new_page()
    page.goto("https://www.glassdoor.co.uk/Job/qa-engineer-jobs-SRCH_KO0,11.htm")
    page.locator("_react=q[key='1007467366491']").click()
    browser.close()

Error:

    playwright._impl._api_types.TimeoutError: Timeout 30000ms exceeded.
=========================== logs ===========================
waiting for selector "_react=q[key='1007467366491']"
============================================================

sandbox example

Are there any more detailed examples for react out there?

hardkoded
  • 18,915
  • 3
  • 52
  • 64
pikk
  • 837
  • 5
  • 21
  • 38

1 Answers1

2

Playwright does not support key filtering at the moment. But you can filter for the job.id which is part of the props:

from playwright.sync_api import sync_playwright

with sync_playwright() as p:
    browser = p.chromium.launch()
    page = browser.new_page()
    page.goto("https://www.glassdoor.co.uk/Job/qa-engineer-jobs-SRCH_KO0,11.htm")
    page.locator("_react=q[job.id=1007630619432]").click()
    browser.close()
hardkoded
  • 18,915
  • 3
  • 52
  • 64
  • 1
    Hi, i have a playwright python issue. There isn't much responses and quality documentation for Playwright Python. i'd appreciate if you can take a look over it, here is the link to the issue, https://stackoverflow.com/questions/71631162/playwright-python-tab-link-not-visible , thanks – Calculate Mar 26 '22 at 19:53