验证qq邮箱登录时遇到滑块验证怎么验证不了,有人知道吗
import timefrom selenium.webdriver import Chrome
from selenium.webdriver.common.by import By
from selenium.webdriver import ActionChains
driver = Chrome()
driver.get('https://mail.qq.com/')
driver.implicitly_wait(3)
driver.maximize_window()通过iframe标签的name属性driver.switch_to.frame('login_frame')通过定位iframe标签,进行切换
loc_if = (By.ID,'login_frame')
iframe_ele = driver.find_element(*loc_if)
driver.switch_to.frame(iframe_ele)
loc01 = (By.ID,'switcher_plogin')
loc_name = (By.ID,'u')
loc_paw = (By.ID,'p')
loc_but = (By.ID,'login_button')
driver.find_element(*loc01).click()输入账号密码
driver.find_element(*loc_name).send_keys('42564719')
driver.find_element(*loc_paw).send_keys('sfsdvsdg')
driver.find_element(*loc_but).click()切换到滑动验证码的iframe中
tcaptcha = driver.find_element('id', "tcaptcha_iframe")
driver.switch_to.frame(tcaptcha)选择拖动滑块的节点
sli_ele = driver.find_element('id', 'tcaptcha_drag_thumb')
act = ActionChains(driver)点击鼠标
act.click_and_hold(sli_ele)移动鼠标
act.move_by_offset(xoffset=180, yoffset=0)释放鼠标
act.release()
act.perform()
time.sleep(10)
driver.quit()
脚本执行后,滑块有移动的动作吗?还是滑块本身就没有定位成功呢? 检查下定位到了没 检查定位 看操作,或者能不能跳过去 主要看下有没有正确定位到滑块
页:
[1]