selenium3 qq登录frame操作
作者:梦一针1、登录QQ邮箱 url='https://mail.qq.com/cgi-bin/loginpage'用户名,密码分别为u,p,login_button
# _*_ coding:utf-8 _*_
from selenium importwebdriver
from selenium.webdriver.common.action_chains importActionChains
importtime
driver = webdriver.Chrome('C:\\Program Files (x86)\\Google\\Chrome\\Application\\chromedriver.exe')
driver.maximize_window()
driver.get('https://mail.qq.com/cgi-bin/loginpage')
time.sleep(5)
driver.find_element_by_name('u').send_keys('2574674466')
driver.find_element_by_name('p').send_keys('')
driver.find_element_by_id('login_button').click()
执行后-无法输入用户名,密码由于登录窗口有-frame,需要先切换-再执行需要加上:
driver.switch_to.frame("login_frame")
driver = webdriver.Chrome('C:\\Program Files (x86)\\Google\\Chrome\\Application\\chromedriver.exe')
driver.maximize_window()
driver.get('https://mail.qq.com/cgi-bin/loginpage')
time.sleep(5)
driver.switch_to.frame("login_frame")
driver.find_element_by_name('u').send_keys('2574674466')
driver.find_element_by_name('p').send_keys('')
driver.find_element_by_id('login_button').click()
作者分享:Selenium3项目实战
页:
[1]