09 2021 档案
摘要:基本认证是允许http用户代理(如:网页浏览器)在请求时,提供用户名和密码的一种方式。 自动化测试中,可以用auth参数传递认证信息 import requests from requests.auth import HTTPBasicAuth def test_auth(): r = reques
阅读全文
摘要:Cookie使用场景 在接口测试过程中, 很多情况下,需要发送的请求附带cookies,才能返回正常的结果。所以在使用python+requests进行接口自动化测试也是同理, 需要在构造接口测试用例时加入cookie。 传递Cookie的两种方式: 1. 请求头headers信息传递 import
阅读全文
摘要:http://hamcrest.org/ import requests from hamcrest import * def test_post_json(self): payload = { "level": 1, "name": "xuefeifei" } r = requests.post(
阅读全文
摘要:import requests from jsonpath import jsonpath def test_post_json(self): payload = { "level": 1, "name": "xuefeifei" } r = requests.post("https://httpb
阅读全文
摘要:import requests class TestDemo: def test_get(self): r = requests.get("https://www.baidu.com/") print(r.status_code) assert r.status_code == 200 def te
阅读全文

浙公网安备 33010602011771号