"""
滑动选择日历
"""
executable_path=r'K:\zhusc\chromedriver.exe'
from selenium import webdriver
from time import sleep
opt=webdriver.ChromeOptions()
opt.add_experimental_option('w3c',False)
driver=webdriver.Chrome(chrome_options=opt,executable_path=executable_path)
"""
无以上3行,会报错
selenium.common.exceptions.WebDriverException:
Message: unknown command:
Cannot call non W3C standard command while in W3C mode
"""
driver.get("http://www.jq22.com/yanshi4976")
driver.maximize_window()
driver.implicitly_wait(10)
driver.switch_to.frame("iframe")
driver.find_element_by_id("appDate").click()
sleep(1)
# 定位要滑动的年、月、日
dwwos = driver.find_elements_by_class_name("dwwo")
year = dwwos[0]
month = dwwos[1]
day = dwwos[2]
action = webdriver.TouchActions(driver)
#滑动的元素 x坐标距离 y坐标距离,有惯性,月份动了,年份还在动
action.scroll_from_el
Selenium如何让滚动条滚动到想选择的目标值?
最新推荐文章于 2022-10-14 14:26:03 发布