selenium3测试126邮箱登录日志
测试邮箱的登录和退出功能

from time import sleep
from selenium import webdriver
from MailClass import Mail
from itertools import islice
import csv
import codecs
from xml.dom.minidom import parse
import jsondriver = webdriver.Chrome()
driver.get("http://www.126.com")driver.implicitly_wait(10)driver.find_element_by_id("switchAccountLogin").click()  ###点击密码登录mail=Mail(driver)

读取txt文件

####### 读取txt文件
with open("./data_file/user_info.txt",'r') as user_file:data=user_file.readlines()
for line in data:user=line[:-1].split(':')mail.login(user[0],user[1])

读取csv文件

####### 读取csv文件
data = csv.reader(codecs.open('./data_file/user_info.csv', 'rb', 'gbk'))for line in islice(data,1,None):###第二行才是账号密码mail.login(line[0],line[1])

读取xml文件

#### 读取xml文件
dom=parse('./data_file/config.xml')
root=dom.documentElementlogin_info=root.getElementsByTagName('login')for login in login_info:username=login.getAttribute("username")password=login.getAttribute("password")mail.login(username,password)

读取json文件

with open("./data_file/user_info.json",'r') as f:data=f.read()
user_list=json.loads(data)
print(user_list)
for user in user_list:mail.login(user["username"],user["password"])

退出邮箱

sleep(2)mail.logout()driver.quit()

使用Mail 类存放登录和退出动作

class Mail:def __init__(self,driver):self.driver=driver###登录###def login(self,username,password):login_frame = self.driver.find_element_by_css_selector('iframe[id^="x-URS-iframe"]')self.driver.switch_to.frame(login_frame)self.driver.find_element_by_name("email").clear()self.driver.find_element_by_name("email").send_keys(username)self.driver.find_element_by_name("password").clear()self.driver.find_element_by_name("password").send_keys(password)self.driver.find_element_by_id("dologin").click()self.driver.switch_to.default_content()###退出###def logout(self):self.driver.find_element_by_link_text('退出').click()

##参考虫师著 Selenium3自动化测试实战 基于python 语言。

selenium3测试126邮箱登录日志相关推荐

  1. python+selenium3解决126邮箱登录出现验证码问题

    研究了好几天,终于解决了126邮箱登录出现的验证码问题!!! 首先需要导包: 1.下载PIL,一个强大的处理图像的库.无法使用pip小工具下载,而且官网没有对应的python3版本,不过可以使用pil ...

  2. selenium自动化测试--126邮箱登录问题总结

    虫师著selenium 2自动化测试实战基于python语言第四章习题4.3.1 126邮箱登录练习问题总结. 练习过程中,参考以下博友的博客顺利完成练习题: https://blog.csdn.ne ...

  3. selenium-动态id定位(126邮箱登录定位实例)

    126邮箱登录自动化实例,有两个注意点:1需要定位到iframe框架内,2id为动态需要使用其他方式进行定位 1 driver.switch_to.frame(driver.find_element_ ...

  4. Python+Selenium模拟126邮箱登录

    通过自学学习写一个简单的自动化测试模拟126邮箱登录.我知道实际的项目不可能这么简单,努力学习 ,争取下次写一个复杂的项目. 重要的事情说三遍:加油!加油!加油!/微笑 import time fro ...

  5. python 实现126邮箱登录

    2019/5/30测试有效,代码仅供参考 #模拟登录网易126邮箱 # usage: py.exe selenuimEx.py import time, sys, re sys.path.append ...

  6. php模拟邮箱登录2017,php 模拟GMAIL,HOTMAIL(MSN),YAHOO,163,126邮箱登录的详细介绍_PHP教程...

    最近一直在忙,赶在这个假期结束的时候,发表一下此文,为了是让这些源码开源出来 当然这些方法可能不可取,但大致应该是这种方向了吧,由于目前做的一个UCHOME港台的站点 咱们策划说要改一下好友邀请里面的 ...

  7. 126邮箱登录(selenium+python)

    2019独角兽企业重金招聘Python工程师标准>>> # -*- coding: utf-8 -*- __author__ = 'xuweiming' import time im ...

  8. 阿里云邮箱登录日志中有异地IP登录是怎么回事?该怎么办?

    注意,请先到阿里云官网 领取幸运券,除了价格上有很多优惠外,还可以参与抽奖.详见:https://promotion.aliyun.com/ntms/act/ambassador/sharetouse ...

  9. python3.6实现126邮箱登录

    在这个实例中需要注意的是:iframe的切换,试了好几种都切换不成功,目前这个是成功的实例,希望可以帮助到大家! from selenium import webdriver from seleniu ...

最新文章

  1. WP8.1 Study4:WP8.1中控件集合应用
  2. 15、如何选择MySQL存储引擎
  3. kirin710f是什么处理器_麒麟710a与麒麟710f哪个好?对比区别哪款性能更好一些
  4. LeetCode 2171. 拿出最少数目的魔法豆(排序)
  5. opengl学习笔记(四)
  6. Android适配64位TBS X5内核
  7. oracle sql执行计划分析
  8. 迪文屏CRC16校验
  9. Google设置新标签页默认地址
  10. 基于梯度下降算法求解线性回归
  11. hexo博客之yilia主题的个性化设置
  12. 使用win32API获取打印机是否处于脱机状态
  13. office修复找不到msi_Microsoft Office安装程序找不到ProPlus.WW\ProPlusWW.msi 弄不了
  14. ATF(Arm Trusted Firmware)/TF-A Chapter 01. 介绍
  15. matlab, 生成一个数值一样的n维列向量
  16. XPE优势与常见问题二
  17. server2008网卡驱动包_网卡工作原理详解
  18. 相机成像---世界坐标系、相机坐标系、图像坐标系和像素坐标系之间的转换关系
  19. 离散选择模型之Gumbel分布
  20. buildroot使用详解

热门文章

  1. requestAnimationFrame,读懂这篇文章就够了
  2. Android利用云盘实现手机上传功能
  3. 制作轮播图思路 ~ 使用JS做一个轮播图,先在脑海里捋一捋逻辑,我的思路是这样的,看图啦:
  4. matlab中 1 10 end,Matlab中“end”的语义是什么?
  5. IT外包劣根难除?自由职客开创IT外包行业新势态
  6. Aspose.cells导出Excel合并行单元格(Datatable)
  7. 2015二级java,2015下半年全国计算机二级Java考试模拟题及答案
  8. 如何在Word 2010中画流程图
  9. java用jintellitype和jna两种方式实现鼠标键盘后台监听
  10. 远特鸿蒙系统,远特通信获“2018年度优秀虚拟运营商”奖:“小而美”也是领军力量...