首页 > V2EX > V2EX-selenium4 使用 TouchActions 的 scroll 方法报错,可有破解之法
2022
05-17

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

396930154:

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

from V2EX-最新主题 https://ift.tt/u3je7kZ

最后编辑:
作者:分享菌
这个作者貌似有点懒,什么都没有留下。

留下一个回复