美文网首页
鼠标滚轮操作

鼠标滚轮操作

作者: 含辞未吐气若幽兰 | 来源:发表于2024-07-02 16:10 被阅读0次

    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)

    相关文章

      网友评论

          本文标题:鼠标滚轮操作

          本文链接:https://www.haomeiwen.com/subject/asgvcjtx.html