python +selenium 登录163邮箱
from selenium import webdriver import user driver=webdriver.Chrome(r'D:\chromedriver_win32\chromedriver.exe') #进入163邮箱 driver.get('https://mail.163.com/') #隐形等待 driver.implicitly_wait(5) #账号密码登录 ele=driver.find_element_by_id('switchAccountLogin').click()
登录账户密码时,因为是iframe表单
提取红色标记的div的xpath
#进入表单
ele1=driver.find_element_by_xpath('//*[@id="loginDiv"]/iframe')
driver.switch_to.frame(ele1)
#执行登录操作
driver.find_element_by_name("email").clear()
driver.find_element_by_name("email").send_keys(user.uesr)
driver.find_element_by_name("password").clear()
driver.find_element_by_name("password").send_keys(user.password)