zoukankan      html  css  js  c++  java
  • python使用selenium自动化实现126邮箱登录的简单实例

     1 #encoding=utf-8
     2 from selenium import webdriver #导入包
     3 import time
     4 
    #选择浏览器驱动 5 driver = webdriver.Chrome(executable_path = "C:\Program Files\Python36\chromedriver") 6 driver.get("http://mail.126.com") #发送get请求 7 passwd_login_link = driver.find_element_by_id("switchAccountLogin") 8 passwd_login_link.click() 9 time.sleep(1) 10 driver.switch_to.frame(driver.find_element_by_xpath("//iframe[contains(@id,'x-URS-iframe')]")) 11 12 user_name = driver.find_element_by_xpath("//input[@name='email']") 13 pass_wd = driver.find_element_by_xpath("//input[@name='password']") 14 login_button =driver.find_element_by_id("dologin") 15 16 user_name.clear() 17 user_name.send_keys("w465898125") 18 pass_wd.send_keys("Wen11281128#m") 19 login_button.click() 20 time.sleep(5) 21 22 assert "退出" in driver.page_source 23 24 logout_link = driver.find_element_by_xpath("//a[text()='退出']") 25 logout_link.click() 26 driver.close()
  • 相关阅读:
    暂时转换
    内置函数⼆
    day13内置函数⼀
    day12⽣成器和⽣成器表达式
    20181031作业
    20181030函数2
    20181029函数1
    20181026
    20181025
    20181024
  • 原文地址:https://www.cnblogs.com/wenm1128/p/11781014.html
Copyright © 2011-2022 走看看