TA的每日心情 | 无聊 4 天前 |
---|
签到天数: 530 天 连续签到: 2 天 [LV.9]测试副司令
|
1测试积点
- import time
- from 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()
复制代码
|
|