from selenium import webdriver
from selenium.webdriver.common.by import By
# 加上参数,禁止 chromedriver 日志写屏
options = webdriver.ChromeOptions()
options.add_experimental_option('excludeSwitches', ['enable-logging'])
# 打开浏览器
wd = webdriver.Chrome(r"D:\chromedriver.exe", options=options)
# 打开网址
wd.get(r"https://mail.163.com/")
# 最多等待5秒
wd.implicitly_wait(5)
# 窗口最大化
wd.maximize_window()
frame1 = wd.find_element(By.XPATH, "//*[contains(@id,'x-URS-iframe')]")
wd.switch_to.frame(frame1)
element = wd.find_element(By.XPATH, "//input[@data-type='email']")
element.clear()
element.send_keys('这里换成你的账号')
element = wd.find_element(By.XPATH, "//input[@data-placeholder='输入密码']")
element.clear()
element.send_keys('这里换成你的密码')
element = wd.find_element(By.XPATH, "//*[@id='dologin']")
element.click()
|