摘要: 阅读全文
posted @ 2018-09-21 11:57 怪圣卡杰 阅读(423) 评论(0) 推荐(0) 编辑
摘要: python接口自动化测试二十六:使用pymysql模块链接数据库 #!/usr/bin/env python# -*- coding: utf-8 -*-# @Time : 2018/5/28 18:51# @Author : StalloneYang# @File : mysql_test.py 阅读全文
posted @ 2018-08-29 11:25 怪圣卡杰 阅读(905) 评论(0) 推荐(0) 编辑
摘要: python接口自动化测试二十七:密码MD5加密 ''' MD5加密 '''# 由于MD5模块在python3中被移除# 在python3中使用hashlib模块进行md5操作import hashlib# 待加密信息str = 'asdas89799,.//plrmf'# 创建md5对象hl = 阅读全文
posted @ 2018-08-29 11:25 怪圣卡杰 阅读(405) 评论(0) 推荐(0) 编辑
摘要: python接口自动化测试二十五:执行所有用例,并生成HTML测试报告 import requestsimport unittestclass TestQQ(unittest.TestCase): '''测试QQ号接口''' # 此注释将展示到测试报告的测试组类 def test_qq(self): 阅读全文
posted @ 2018-08-29 11:24 怪圣卡杰 阅读(646) 评论(0) 推荐(0) 编辑
摘要: python接口自动化测试二十四:上传多个附件,参数化 # 添加多个附件参数化files = [("1.png", "1.png") ("2.png", "2.png") ]def addFiles(files, n=1): file = [] for i in list(range(n)): a 阅读全文
posted @ 2018-08-29 11:23 怪圣卡杰 阅读(572) 评论(0) 推荐(0) 编辑
摘要: python接口自动化测试二十三:文件上传 # 以禅道为例: 一、创建一个类,类里面写一个登录方法: import requestsclass LoginZentao(): def __init__(self, s): # 初始化 self.s = s # 定义一个全局的s def login(se 阅读全文
posted @ 2018-08-29 11:22 怪圣卡杰 阅读(593) 评论(0) 推荐(0) 编辑
摘要: python接口自动化测试二十二:文件下载 文件下载类型: Content-Type: octets/stream 一般为文件类型: 文件下载类型: Content-Type: octets/stream 一般为文件类型: 文件下载类型: Content-Type: octets/stream 一般 阅读全文
posted @ 2018-08-29 11:21 怪圣卡杰 阅读(749) 评论(0) 推荐(0) 编辑
摘要: python接口自动化测试二十:函数写接口测试 # coding:utf-8import requestsimport refrom bs4 import BeautifulSoup# s = requests.session() # 全局的sdef get_token(s): ''' fuctio 阅读全文
posted @ 2018-08-29 11:20 怪圣卡杰 阅读(471) 评论(0) 推荐(0) 编辑
摘要: python接口自动化测试二十一:类和方法 # 类和方法class Count(): def __init__(self, aaa, bbb): # 初始化 # 可以放公共的参数 print('实例化的时候,会执行init的内容') self.a = aaa self.b = bbb # 加了sel 阅读全文
posted @ 2018-08-29 11:20 怪圣卡杰 阅读(445) 评论(0) 推荐(0) 编辑
摘要: python接口自动化测试十九:函数 # 函数a = [1, 3, 6, 4, 85, 32, 46]print(sum(a)) # sum,求和函数def add(): a = 1, b = 2, return a + bprint(add())def add(a, b): # 都必填 retur 阅读全文
posted @ 2018-08-29 11:19 怪圣卡杰 阅读(350) 评论(0) 推荐(0) 编辑
摘要: python接口自动化测试十八:使用bs4框架爬取图片 # 爬图片# 目标网站:http://699pic.com/sousuo-218808-13-1.htmlimport requestsfrom bs4 import BeautifulSoupimport osr = requests.get 阅读全文
posted @ 2018-08-29 11:18 怪圣卡杰 阅读(748) 评论(0) 推荐(0) 编辑
摘要: python接口自动化测试十七:使用bs4框架进行简单的爬虫 安装:beautifulsoup4 from bs4 import BeautifulSoupyoyo = open('yoyo.html', 'r') # 以读的方式打开“yoyo.html”文件# print(yoyo.read()) 阅读全文
posted @ 2018-08-29 11:17 怪圣卡杰 阅读(294) 评论(0) 推荐(0) 编辑
摘要: python接口自动化测试十六:unittest完成用例 import unittestimport requestsdef add(a, b): print('前置条件!!!!!:如登录') return a + bclass TestAAA(unittest.TestCase):# 一次性的前置 阅读全文
posted @ 2018-08-29 11:16 怪圣卡杰 阅读(357) 评论(0) 推荐(0) 编辑
摘要: python接口自动化测试十四: 用正则表达式提取数据 import requests import re url = 'xxxx' r = requests.post(url) # 正则公式: postid = re.findall(r"(.+?)", r.url) # r.url:匹配的url对 阅读全文
posted @ 2018-08-29 11:13 怪圣卡杰 阅读(6291) 评论(0) 推荐(0) 编辑
摘要: python接口自动化测试十五:解决密码动态,无法登录情况 解决问题:每次密码都是变化的,无法通过账号密码登录(总不能每次去fiddler复制吧????)解决思路:1.先用selenium调用浏览器(不会selenium的自己想办法了),2.登录后从浏览器里面抓取cookies3.把cookies传 阅读全文
posted @ 2018-08-29 11:13 怪圣卡杰 阅读(486) 评论(0) 推荐(0) 编辑
摘要: python接口自动化测试十三:url编码与解码 # url编码与解码 from urllib import parse url = 'http://zzk.cnblogs.com/s/blogpost?Keywords=中文' a = '中文' b = parse.quote(a) # 转urle 阅读全文
posted @ 2018-08-29 11:07 怪圣卡杰 阅读(547) 评论(0) 推荐(0) 编辑
摘要: python接口自动化测试十二:对返回的json的简单操作 # 1、requests里面自带解析器转字典 print(r.json()) print(type(r.json())) # 取出json中的'result_sk_temp'字段 # {"resultcode":"200","reason" 阅读全文
posted @ 2018-08-29 11:06 怪圣卡杰 阅读(2390) 评论(0) 推荐(0) 编辑
摘要: python接口自动化测试十一:传参数:data与json # 传json参数 import requests url = 'xxxxxxxx' body = { 'xxx': 'xxx', 'xxx': 'xxx' } # body是json格式的 r = requests.post(url, j 阅读全文
posted @ 2018-08-29 11:02 怪圣卡杰 阅读(2275) 评论(0) 推荐(0) 编辑
摘要: python接口自动化测试九:重定向相关 allow_redirects=False 不重定向 # 获取重定向后的地址loc = r.headers # 相对地址host = 'https://i.cnblogs.com/'url = host+'EditPosts.aspx?opt=1' loc 阅读全文
posted @ 2018-08-29 10:59 怪圣卡杰 阅读(1147) 评论(3) 推荐(0) 编辑
摘要: python接口自动化测试十:字典、字符串、json之间的简单处理 # 字典a = None # None = nullb = False # booleanc, d = 12, 10.6 # int floate = 'asdd' # strf = ['s', 'e'] # list,数组,可增删 阅读全文
posted @ 2018-08-29 10:59 怪圣卡杰 阅读(463) 评论(0) 推荐(0) 编辑