这是自己用的例子,记录一下,以后好翻看。
主要涉及的是定位元素。
from playwright.sync_api import sync_playwright
playwright = sync_playwright().start()
browser = playwright.chromium.launch(headless=False,slow_mo=2000)
page = browser.new_page()
page.goto("https://www.baidu.com")
page.locator('#kw').fill('flaywright')
page.locator("#su").click()
page.go_back()
page.locator('.s_ipt').fill('aaaaa')
page.locator('#su').click()
page.go_back()
page.locator('input#kw').fill('bbbbb')
page.locator('#su').click()
page.go_back()
page.locator('div > form > span > input.s_ipt').fill('cccc')
page.locator('#su').click()
browser.close()
标签:playwright,su,click,locator,实例,自用,page,fill
From: https://blog.51cto.com/u_16257798/7502509