#encode =utf-8
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import time
from selenium.webdriver.common.action_chains import ActionChains
driver=webdriver.Firefox(executable_path="C:\\webdriver\geckodriver.exe")
driver.implicitly_wait(10)
driver.maximize_window()
driver.get("http://mail.126.com")
time.sleep(5)
driver.find_element_by_id("switchAccountLogin").click()
driver.switch_to.frame(driver.find_element_by_xpath("//iframe[contains(@id,'URS-iframe')]"))
userName=driver.find_element_by_xpath("//input[contains(@id,'auto-id')]")
userName.send_keys("zxw18050403070")
pwd=driver.find_element_by_name("password")
pwd.send_keys("18050403070zxw")
driver.find_element_by_id("dologin").click()
driver.switch_to.default_content()
driver.implicitly_wait(10)
time.sleep(2)
driver.find_element_by_xpath("//*[@id='_mail_tabitem_1_4']").click()
time.sleep(2)
driver.find_element_by_xpath("//div[contains(@id,'mail_button_21')]").click()
time.sleep(2)
driver.find_element_by_xpath("//input[@id='input_N']").send_keys("张三")
time.sleep(5)
driver.find_element_by_xpath("//dd[@class='is0']/div[contains(@id,'_mail_input_6')]/input[1]").send_keys("123456@qq.com")
time.sleep(5)
driver.find_element_by_xpath("//dd[@class='is0']/div[contains(@id,'_mail_input_7')]/input[1]").send_keys("18650725020")
time.sleep(5)
driver.find_element_by_xpath("//div[contains(@id,'mail_button_28')]").click()
time.sleep(5)
action = ActionChains(driver)
above = driver.find_element_by_xpath("//tr[contains(@aria-label,'张三')]")
action.move_to_element(above).perform()
time.sleep(2)
driver.find_element_by_xpath("//div[@title='删除']/span").click()
time.sleep(2)
driver.find_element_by_xpath("//span[contains(.,'确 定')]").click()
time.sleep(5)

driver.quit()