栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Python

Python自学记录--初级滑块,邮箱例子

Python 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

Python自学记录--初级滑块,邮箱例子

from selenium import webdriver
from time import sleep
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as ec
from selenium.webdriver.common.by import By
from selenium.webdriver import  ActionChains
 
driver = webdriver.Chrome()
driver.get('https://mail.qq.com/')
sleep(0.4)
driver.switch_to.frame('login_frame')
driver.find_element_by_id('u').send_keys('785214563')
sleep(0.4)
driver.find_element_by_id('p').send_keys('1020300.0')
sleep(0.4)
WebDriverWait(driver,10).until(ec.element_to_be_clickable((By.ID,"login_button")))
driver.find_element_by_id('login_button').click()
sleep(1)
driver.switch_to.frame('tcaptcha_iframe')
sleep(0.4)
#拖动滑块
while True:
    slider = WebDriverWait(driver,20).until(ec.element_to_be_clickable((By.ID,'tcaptcha_drag_thumb')))
    distance = 175
    actions = webdriver.ActionChains(driver)
    #点击开始拖拽
    actions.click_and_hold(slider)
    actions.pause(0.2)
    actions.move_by_offset(distance+5,0)
    sleep(0.2)
    actions.move_by_offset(-10, 0)
    actions.release()
    actions.perform()
    sleep(2)
    try:
        shuaxin = WebDriverWait(driver,1).until(ec.presence_of_element_located((By.CLASS_NAME,"tcaptcha-embed-contrl show-reload")))
        driver.find_element_class_name("tcaptcha-embed-contrl show-reload").click()
    except:
        driver.quit()
        break

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/286232.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号