自动登录163邮箱,困难在于用户名和密码的框控件获取,动态id原因会导致定位元素失败。
# coding = utf-8
import time
from selenium import webdriver
driver = webdriver.Chrome()
driver.maximize_window()
driver.get('http://www.mail.163.com')
time.sleep(2)
driver.switch_to.frame(0)
driver.find_element_by_css_selector(".dlemail").clear()
driver.find_element_by_css_selector("[class='j-inputtext dlemail']").send_keys("username")
driver.find_element_by_css_selector(".j-inputtext.dlpwd").clear()
driver.find_element_by_css_selector(".dlpwd").send_keys("password")
driver.find_element_by_css_selector(".loginbox").click()
time.sleep(5)
driver.quit()
参考:https://blog.csdn.net/young_gril/article/details/82754315
网友评论