playwright-python

Using Playwright for Python, how do I select (or find) an element?

走远了吗. 提交于 2021-01-28 05:54:05
问题 I'm trying to learn the Python version of Playwright. See here I would like to learn how to locate an element, so that I can do things with it. Like printing the inner HTML, clicking on it and such. The example below loads a page and prints the HTML from playwright import sync_playwright with sync_playwright() as p: browser = p.chromium.launch(headless=False) page = browser.newPage() page.goto('http://whatsmyuseragent.org/') print(page.innerHTML("*")) browser.close() This page contains an