反应定位器示例
React locator example
我试图了解反应选择器如何根据 https://playwright.dev/docs/selectors#react-selectors 工作。所以我正在剧作家沙盒中尝试一些东西。好像找不到react组件。
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()
错误:
playwright._impl._api_types.TimeoutError: Timeout 30000ms exceeded.
=========================== logs ===========================
waiting for selector "_react=q[key='1007467366491']"
============================================================
是否有更详细的反应示例?
剧作家暂时不支持按键过滤。但是您可以过滤 job.id
,它是 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()
我试图了解反应选择器如何根据 https://playwright.dev/docs/selectors#react-selectors 工作。所以我正在剧作家沙盒中尝试一些东西。好像找不到react组件。
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()
错误:
playwright._impl._api_types.TimeoutError: Timeout 30000ms exceeded.
=========================== logs ===========================
waiting for selector "_react=q[key='1007467366491']"
============================================================
是否有更详细的反应示例?
剧作家暂时不支持按键过滤。但是您可以过滤 job.id
,它是 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()