coding=utf-8
Python+Playwright自动化测试-45-鼠标滚轮操作
导入模块
from playwright.sync_api import Playwright, sync_playwright, expect
def run(playwright: Playwright) -> None:
browser = playwright.chromium.launch(headless=False)
context = browser.new_context()
page = context.new_page()
page.goto("https://www.runoob.com/")
page.wait_for_timeout(1000)
# 垂直滚动条滚10次,每次滚100
for i in range(10):
page.mouse.wheel(delta_x=0, delta_y=100)
page.wait_for_timeout(1000)
context.close()
browser.close()
with sync_playwright() as playwright:
run(playwright)
网友评论