小肥羊要进步

Ctrip注册自动化的坑

写个自动化简单线性脚本

Ctrip注册

1.点击同意

 

 

2.滑动

 

 

 

 

报错1:

 

AttributeError: 'list' object has no attribute 'click'

因为find element by 不应该是elements

 

 

 


from selenium.webdriver.common.action_chains import ActionChains

from selenium import webdriver

import time
driver=webdriver.Chrome()
driver.get("https://passport.ctrip.com/user/reg/home")
driver.maximize_window()
driver.find_element_by_xpath("//div[@id='agr_pop']//div[@class='pop_footer']/a[2]").click()

time.sleep(3)
sour=driver.find_elements_by_xpath("//div[@class=' cpt-drop-box']//div[@class='cpt-drop-btn']")
ele=driver.find_elements_by_xpath("//div[@class=' cpt-drop-box']//div[@class='cpt-bg-bar']")
#拖动滑块
ActionChains(driver).drag_and_drop_by_offset(sour, 100, 2000)
ActionChains(driver).perform()

posted on 2021-05-26 10:07  小肥羊要进步  阅读(73)  评论(0编辑  收藏  举报

导航