타오바오 슬레이드 액션체인
# 等待滑动验证码出现,超时时间为5秒,每0.5秒检查一次<font></font>
# 大部分情况不会出现滑动验证码,所以如果有需要可以注释掉下面的代码<font></font>
# sleep(5)<font></font>
WebDriverWait(self.browser, 5, 0.5).until(EC.presence_of_element_located((By.ID, "nc_1_n1z"))) #等待滑动拖动控件出现<font></font>
try:<font></font>
swipe_button = self.browser.find_element_by_id('nc_1_n1z') #获取滑动拖动控件<font></font>
<font></font>
#模拟拽托<font></font>
action = ActionChains(self.browser) # 实例化一个action对象<font></font>
action.click_and_hold(swipe_button).perform() # perform()用来执行ActionChains中存储的行为<font></font>
action.reset_actions()<font></font>
action.move_by_offset(580, 0).perform() # 移动滑块<font></font>
<font></font>
except Exception as e:<font></font>
print ('get button failed: ', e)<font></font>