大佬麻烦看看,使用 TouchActions.scroll_from_element() 方法,传入的了元素和坐标,没有报错,但是也不好使,不知道啥原因,有懂得大佬给瞅瞅嘛.谢谢!

from selenium import webdriver
from selenium.webdriver.common.by import By
from time import sleep

options = webdriver.ChromeOptions()
options.add_experimental_option('w3c', False)
options.add_experimental_option("excludeSwitches", ['enable-automation'])

driver = webdriver.Chrome(options=options)
driver.get('https://www.jq22.com/yanshi4976')
sleep(3)
driver.switch_to.frame('iframe')
driver.find_element(By.CSS_SELECTOR, '#appDate').click()

dwwos = driver.find_elements(By.CSS_SELECTOR,'.dwwo')
year, month, date = dwwos[0], dwwos[1], dwwos[2]

action = webdriver.TouchActions(driver)
action.scroll_from_element(year,0, 5).perform()
sleep(2)
action.scroll_from_element(month,0,30).perform()
sleep(2)
action.scroll_from_element(date,0,10).perform()

浏览器截图


代码没报错,但是不好使


↙↙↙阅读原文可查看相关链接,并与作者交流