如何使用Playwright Python同步API将所有<select>元素设置为指定值
如何使用Playwright Python同步API将所有元素数量,再通过
nth(index)来逐个定位操作:from playwright.sync_api import sync_playwright with sync_playwright() as p: browser = p.chromium.launch() page = browser.new_page() page.goto("你的目标页面URL") selects_locator = page.locator("select") # 先拿到所有匹配元素的数量 select_count = selects_locator.count() # 按索引逐个操作 for i in range(select_count): selects_locator.nth(i).select_option("raw") browser.close()
额外小提示
- 要是你的
相关产品推荐
相关产品推荐

