V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
wwoww
V2EX  ›  问与答

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

  •  
  •   wwoww · May 17, 2022 · 807 views
    This topic created in 1453 days ago, the information mentioned may be changed or developed.

    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 方法吗?

    No Comments Yet
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3388 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 34ms · UTC 10:44 · PVG 18:44 · LAX 03:44 · JFK 06:44
    ♥ Do have faith in what you're doing.