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()
  • 相关阅读:
    python删除hbase一整列数据
    selenium基本操作
    python去除html标签及标签里面的内容
    Ambari-server 启动错误
    scala 命名规范
    HDFS坏块修复
    Nodejs+MySql+Echart(html模板渲染)
    Ambari openssl错误
    设置mysql 远程连接
    JMS 简介笔记
  • 原文地址:https://www.cnblogs.com/wenm1128/p/11781014.html
Copyright © 2011-2022 走看看