- 博客(113)
- 收藏
- 关注
原创 062自动发送邮件
# -*- coding:utf-8 -*-# smtplib模块# python内置对SMTP的支持,可以发送纯文本邮件、HTML邮件以及带附件的邮件# python对SMTP支持有smtplib和email两个模块,email负责构造邮件,smtplib负责发送邮件# 注意:使用前需要开启SMTP服务# 案例:使用163邮箱来结合smtp模块发送邮件,准备工作:客户端授权码打开...
2019-05-18 00:15:47
569
原创 061测试报告生成
#文件名为test_alibaba.py# -*- coding:utf-8 -*-from selenium import webdriverimport unittest #导入测试模块from time import sleepclass shizhan(unittest.TestCase): def setUp(self):...
2019-04-16 23:59:56
279
原创 060web测试实战
# -*- coding:utf-8 -*-from selenium import webdriverimport unittest #导入测试模块from time import sleepclass shizhan(unittest.TestCase): def setUp(self): self.driver=w...
2019-04-15 22:55:19
301
原创 059用例综合框架管理
#当测试用例不断增多的时候,如果所有测试用例还写在一个py文件里,会很麻烦,所以要分开进行管理,可以分成5个文件进行管理# 例:Tset_project文件下包含5个文件:# 1.StartEnd.py setUP和tearDown管理# 2.calculatory.py 加减法运算方法的实现# 3.test_add.py 加法测试用例# 4.test_sub.py ...
2019-04-07 20:32:21
233
原创 058用例公共部分合并
# -*- coding:utf-8 -*-from unittest1 import *import unittestclass hebing(unittest.TestCase): #合并了开始执行测试用例的环境配置,恢复环境的阶段,hebing继承了TestCase类 def setUp(self): print("Start Test!") ...
2019-04-03 21:57:01
207
原创 057断言
# #断言# 断言内容是自动化脚本的重要内容,正确设置断言以后才能帮助我们判断测试用例执行结果# 断言方法:# 1.assertEqual(a,b) 判断a==b# 2.assertNotEqual(a,b) 判断a!=b# 3.assertTrue(x)bool(x)is T...
2019-04-01 22:52:27
281
原创 057unittest(单元测试)
# -*- coding:utf-8 -*-#unittest案例#构造一个类,包含整数加法运算class Math: def __init__(self,a,b): #初始化a和b self.a=int(a) self.b=int(b) def add(self): ...
2019-04-01 22:33:19
162
原创 056调用数据驱动测试
# -*- coding:utf-8 -*-from selenium import webdriverfrom time import sleepfrom 055数据驱动测试 import * # *代表所有类driver=webdriver.Chrome()driver.get('https://passport.csdn...
2019-03-26 23:41:45
145
原创 055数据驱动测试
# -*- coding:utf-8 -*-from selenium import webdriverfrom time import sleepclass login(): def user_login(self, driver,zhanghu,password): driver.find_element_by_css_selector('div.main-se...
2019-03-26 23:40:38
193
原创 054接上篇跨模块调用
from 053模块化驱动测试 import * #调用所有方法 053模块化驱动测试为文件名 from selenium import webdriverfrom time import sleepdriver = webdriver.Chrome()driver.get('https://passport.csdn.net/login')driver.implicitly_wa...
2019-03-25 23:12:24
227
原创 053模块化驱动测试
# -*- coding:utf-8 -*-from selenium import webdriverfrom time import sleepclass login(): def user_login(self,driver): driver.find_element_by_css_selector('div.main-select>ul>:nt...
2019-03-25 21:06:12
238
原创 0052读取EXCEL并把值写入到selenium定位中
# -*- coding:utf-8 -*-from selenium import webdriverfrom time import sleepimport xlrddriver=webdriver.Chrome()driver.get("https://www.baidu.com/index.php?tn=monline_3_dg")driver.find_element_by...
2019-03-20 22:15:56
451
原创 0051python读取EXCEL表格
# -*- coding:utf-8 -*-import xlrdfrom time import sleepfilepath=r'E:\dd.xlsx' #文件赋值zhuanma=filepath.encode('utf-8') #定义了文件编码data=xlrd.open_workbook(filepath) #打开文件...
2019-03-20 21:49:09
145
原创 050读取Excel数据
# -*- coding:utf-8 -*-from selenium import webdriverimport xlrd#读取文件路径file_path=r'E:\练习读取Excel用.xlsx'#获取文件数据data=xlrd.open_workbook(file_path)#获取sheetsheet_data=data.sheet_by_name('Sheet1')#...
2019-01-16 23:54:42
170
原创 049使用cookie绕过验证码自动登录
# _*_ coding:utf-8 _*_#案例绕过验证码自动登录csdn网站#重点是要抓包工具fiddler,抓到name和value#PS,反正我是没抓到过。。。。。from selenium import webdriverfrom time import sleepfrom selenium.common.exceptions import NoSuchElementEx...
2018-12-11 23:25:25
669
原创 048cookie处理
# _*_ coding:utf-8 _*_#什么是cookie#cookie是储存在用户本地终端的数据,实际上是一小段文本信息#cookie的作用#帮助web站点保存有关访问者的信息,方便用户访问,如记住用户名密码实现自动登录#案例:查看访问CSDN时的cookie内容from selenium import webdriverfrom time import sleepdri...
2018-12-10 01:13:06
201
原创 047截图
# _*_ coding:utf-8 _*_#分别打开百度首页和阿里巴巴首页截图from selenium import webdriverfrom time import sleep,ctimefrom selenium.common.exceptions import NoSuchElementExceptiondriver=webdriver.Chrome()driver.im...
2018-12-04 00:41:33
207
原创 046浏览器滚动条操作
# _*_ coding:utf-8 _*_from selenium import webdriverfrom time import sleepfrom selenium.common.exceptions import NoSuchElementExceptiondriver=webdriver.Chrome()driver.get("https://www.baidu.com/...
2018-12-03 01:08:42
161
原创 045文件上传
# _*_ coding:utf-8 _*_#案例:上传美女图片到百度进行搜索from selenium import webdriverfrom selenium.common.exceptions import NoSuchElementExceptiondriver=webdriver.Chrome()driver.get("https://www.baidu.com/")dr...
2018-12-03 00:30:48
145
原创 044多窗口切换操作
# _*_ coding:utf-8 _*_from selenium import webdriverfrom selenium.common.exceptions import NoSuchElementException #调用异常类from time import sleep,ctimefrom selenium.webdriver.comm...
2018-11-30 00:31:54
289
原创 042frame嵌套页面定位
# _*_ coding=utf-8 _*_from selenium import webdriverfrom selenium.common.exceptions import NoSuchElementException #导入异常类from time import ctime,sleep#因为没有Html文件,故按大概意思写的,执行不通,纯属偷懒,嘿嘿drive...
2018-11-29 00:29:27
179
原创 041隐式等待(全局等待)
#隐式等待#隐式等待又叫全局等待,是针对所有的元素的一个等待from selenium import webdriverfrom selenium.common.exceptions import NoSuchElementException #导入没有元素的异常类from time import sleep,ctimedriver=webdriver.Chrome()drive...
2018-11-28 00:56:25
1180
原创 040显示等待(单个元素等待)
# 元素等待# 1.元素等待是一个针对某一个元素进行相关等待判定# 2.隐式等待不针对某一个元素进行等待,全局元素等待# a.相关模块# WebDriverWait显示等待针对元素比用# expected_conditions 预期条件类(里面包含方法可以调用,用于显示等待)# NoSuchElementException 用于隐士等待抛出异常# By用于元素定位from s...
2018-11-28 00:02:30
257
原创 043警告弹窗处理
from selenium import webdriverfrom time import sleepdriver=webdriver.Chrome()driver.get("https://www.baidu.com/")driver.find_element_by_link_text("设置").click()sleep(1)driver.find_element_by_lin...
2018-11-27 00:38:20
241
原创 039键盘操作
from selenium import webdriverfrom time import sleepfrom selenium.webdriver.common.keys import Keys #导入键盘操作类#案例1、在百度输入框里输入“好好学习”,然后复制到搜狗输入框里driver=webdriver.Chrome()driver.get("https://www.baid...
2018-11-15 00:37:51
145
原创 0038鼠标操作
#!/usr/bin/python#vim:set fileencoing=<enconding name>:from selenium import webdriverfrom time import sleepfrom selenium.webdriver.common.action_chains import ActionChains #导入相关鼠标操作类#思路实现...
2018-11-12 01:10:55
126
原创 0037元素定位下拉菜单&层级定位
#!/usr/bin/python#vim:set fileencoing =<enconding name>:from selenium import webdriverfrom time import sleepfrom selenium.webdriver.support.ui import Select #导入select包driver=webdriver.C...
2018-11-06 00:50:11
506
原创 0036元素定位class
#!/usr/bin/python#vim:set fileencoing=<enconding name>:#Css定位# selenium极力推荐使用CSS定位,而不是xpath定位,原因是css定位比xpath定位速度快,# 语法也更加简洁#CSS常用的定位方法:# 1. find_element_by_css_selector()# 2. #id id选择器...
2018-11-06 00:49:06
445
原创 0035元素定位xpath(2)
#!/usr/bin/python#vim:set fileencoing=<enconding name>:#Xpath层级与逻辑定位#简单来说就是取绝对路径的一部分元素进行定位from selenium import webdriverfrom time import sleepdriver=webdriver.Chrome()driver.get("http:/...
2018-11-06 00:48:11
232
原创 0034元素定位xpath(1)
#!/usr/bin/python#vim:set fileencoing=<enconding name>:#Xpath即为XML路径语言,它是一种用来确定XML文档中某部分位置的语言。Xpath#基于XML的树状结构,提供在数据结构树中找寻节点的能力。#Xpath的相对路径与绝对路径from selenium import webdriverfrom time i...
2018-11-06 00:47:26
169
原创 0033元素定位link_text
#!/usr/bin/python#vim:set filleencoing=<encoding name>:#link_text定位是根据超链接文字进行定位from selenium import webdriverfrom time import sleepdriver=webdriver.Chrome()driver.get("https://www.baidu.c...
2018-11-06 00:46:34
269
原创 0032元素定位class_name
#!/usr/bin/python#vim:set filleencoing=<enconding name>:#使用class_name定位from selenium import webdriverfrom time import sleep#加载谷歌浏览器driver=webdriver.Chrome()#请求网址driver.get("https://www....
2018-11-06 00:45:48
277
原创 0031元素定位tag_name
#使用tag_name进行定位from selenium import webdriverfrom time import sleepdriver=webdriver.Chrome()driver.get("http://www.qq.com/")driver.find_elements_by_tag_name("input")[0].send_keys("selenium")sle...
2018-11-06 00:44:58
312
原创 0030元素定位id和name
#案例# 打开百度首页,在自动搜索框里,输入“selenium我要自学网”关键词# 然后点击搜索按钮,查看搜索页面#使用id和name的定位from selenium import webdriverfrom time import sleep,ctimedriver=webdriver.Chrome() ...
2018-11-05 00:41:27
179
原创 0029浏览器的操作
# 浏览器窗口大小设置# 页面前进# 页面刷新#导入驱动from selenium import webdriverfrom time import sleepget_driver=webdriver.Chrome() #加载谷歌驱动get_driver.get("https://www.baidu.com/") #打开百度get_dr...
2018-11-05 00:40:42
112
原创 0028第一个自动化脚本
#!/usr/bin/python#http://p.weather.com.cn/2018/08/2921973.shtml#p=1#请求Http的import urllibimport urllib.request#正则匹配的库import re#定义一个方法,加载这个页面def load_page(url): request=urllib.request.Reque...
2018-11-05 00:40:10
159
原创 0027爬取图片
#!/usr/bin/python#http://p.weather.com.cn/2018/08/2921973.shtml#p=1#请求Http的import urllibimport urllib.request#正则匹配的库import re#定义一个方法,加载这个页面def load_page(url): request=urllib.request.Reque...
2018-11-05 00:39:41
186
原创 0026多进程
#!/usr/bin/pythonfrom time import ctime,sleep#导入多进程包import multiprocessing#定义一个对象def chi(content,loop): for i in range(loop): print("我在吃 %s %s" %(content,ctime())) sleep(3)d...
2018-11-05 00:39:08
135
原创 0025多线程
#多线程是指在从软件或者硬件长实现多个线程并发的执行的技术#案例:让学生同时进行读和写的操作#导入系统时间和睡眠时间from time import ctime,sleep#导入多线程包import threading#定义一个吃的方法def eat(mifan,loop): for a in range(loop): print("我要吃%s %s" %(...
2018-11-05 00:38:39
145
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人