V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
396930154
V2EX  ›  问与答

selenium4 使用 TouchActions 的 scroll 方法报错,可有破解之法

  •  
  •   396930154 · 2022-05-17 18:37:51 +08:00 · 469 次点击
    这是一个创建于 725 天前的主题,其中的信息可能已经有所发展或是发生改变。

    selenium 4.1.0 ChromeDriver 97.0.4692.71 Google Chrome 97.0.4692.71

    示例代码:

    print('start')

    from selenium import webdriver

    from selenium.webdriver.common.touch_actions import TouchActions

    from selenium.webdriver.chrome.service import Service as ChromeService

    options = webdriver.ChromeOptions()

    options.add_experimental_option("excludeSwitches", ["enable-automation"])

    options.add_experimental_option("useAutomationExtension", False)

    options.add_experimental_option('w3c', False)

    service = ChromeService(executable_path=CHROMEDRIVER_PATH)

    driver = webdriver.Chrome(service=service, options=options)

    driver.get('https://www.v2ex.com/')

    actions = TouchActions(driver)

    actions.scroll(100,500).perform()

    print('end')

    去掉 options.add_experimental_option('w3c', False)这句代码会报如下错误:selenium.common.exceptions.WebDriverException: Message: unknown command: Cannot call non W3C standard command while in W3C mode

    selenium 版本不降,w3c 且必须设置为 True 的时候还有办法使用 TouchActions 的 scroll 方法吗?

    目前尚无回复
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   3185 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 23ms · UTC 00:10 · PVG 08:10 · LAX 17:10 · JFK 20:10
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.