当前位置:网站首页>Interface Automation Testing Basics
Interface Automation Testing Basics
2022-08-10 13:19:00 【Jerry Lee~】
I. Common methods of understanding the requests library
The third-party library for python: pip install requests
Knowledge point: pytest's default test case rules
1. The module name must end with test_ or _test.
2. The class name must start with Test
3. The test case name must start with test_
post,delete,put,getAdd, delete, modify, query restful
def get(url, params=None, **kwargs): #Send get requestdef post(url, data=None, json=None, **kwargs): #Send post requestdata is a form parameterjson is json data parameterdef put(url, data=None, **kwargs): #Send put requestdef delete(url, **kwargs): #Send delete request----------------------The first four methods will call the following methods-------------------------def requests.request(method, url, **kwargs): #Send the request according to the request method of the method passing parameters----------------------The previous method calls the following request method-----------------------def session.request(self,method,url,params=None,data=None,headers=None,cookies=None,files=None,auth=None,timeout=None,allow_redirects=True,proxies=None,hooks=None,stream=None,verify=None,cert=None,json=None,):---------------------------------------------------------------------------------def session(): #Get the session objectmethod: request method
url: request path
params: get request parameters
data=None can be a post or put parameter
json=None The second way to pass parameters for post requests
headers=None Request headers
cookies=None cookie information in the request header
files=Nnoe file upload
stream=None File Download
Second, common methods of understanding response
- res.txt Return String
- res.content Returns byte data
- res.json() Returns json data, python is a dictionary
- res.status_code Returns the status code
- res.reason Returns status information
- res.cookies Returns the response cookie
- res.encoding Returns the response encoding
- res.headers Returns response headers
- res.request.xxx returns some requested data
Three, actual combat
get request passes parameters through params
The post request passes parameters through data and json

1. Form file transfer parameters: Content-Type: form-data (multipart/form-data), which supports uploading files FormType;
2. Form parameters: Content-Type: x-www-form-urlencoded, interface request of form type;
3. Text raw parameters: json: Content-Type: application/json (supports various native types, JSON type interface requests);
4, binary binary parameter: Content-Type: Content-Type: application/octet-stream (binary, stream type interface request): Corresponding to Content-Type: application/octet-stream in the http request, onlyBinary data can be uploaded, usually used to upload files. Since there is no key value, only one file can be uploaded at a time;
Fourth, authentication (cookie authentication, session authentication and token authentication)
Identify whether you have permission to access the interface.
Both sessions and tokens can be transmitted through cookies.
Principle
cookies: stored in the browser, with size limit and status;
session: stored in the server, the server has resource overhead, distributed and cross-system is not easy to achieve;
Token: The client can save the Token anywhere, unlimited and stateless, which is conducive to distributed deployment.
边栏推荐
- kubernetes介绍
- Alibaba Cloud Jia Zhaohui: Cloud XR platform supports Bizhen Technology to present a virtual concert of national style sci-fi
- sprintboot项目通过interceptor和filter实现接入授权控制
- 专有云ABC Stack,真正的实力派!
- Mysql—— 内连接、左连接、右连接以及全连接查询
- Codeforces Round #276 (Div. 1) B. Maximum Value
- 想问下大佬们 ,cdc oracle初始化一张300万的表任务运行着后面就这个错 怎么解决哇
- 金山云要飘到哪里?
- 燃炸!字节跳动成功上岸,只因刷爆LeetCode算法面试题
- mSystems | 中农汪杰组揭示影响土壤“塑料际”微生物群落的机制
猜你喜欢

kubernetes介绍

实践为主,理论为辅!腾讯大佬MySQL高阶宝典震撼来袭!

MYSQL误删数据恢复
![ArcMAP出现-15的问题无法访问[Provide your license server administrator with the following information:Err-15]](/img/da/b49d7ba845c351cefc4efc174de995.png)
ArcMAP出现-15的问题无法访问[Provide your license server administrator with the following information:Err-15]

漏洞管理计划的未来趋势

中科院深圳先进技术院合成所赵国屏院士组2022年招聘启事

一个 CRM One Order Application log 的单元测试报表

生成树协议STP(Spanning Tree Protocol)

Solution for "Certificate not valid for requested usage" after Digicert EV certificate signing

鸿蒙开发从hello world开始
随机推荐
11 + chrome advanced debugging skills, learn to direct efficiency increases by 666%
娄底污水处理厂实验室建设管理
多线程下自旋锁设计基本思想
LeetCode·每日一题·640.求解方程·模拟构造
47Haproxy Cluster
Twikoo腾讯云函数部署转移到私有部署
10 款更先进的开源命令行工具
C#WPF 图片在显示时没有问题,但在运行时图片显示不出来的解决
Proprietary cloud ABC Stack, the real strength!
娄底干细胞制备实验室建设须知要求
mSystems | 中农汪杰组揭示影响土壤“塑料际”微生物群落的机制
Network Saboteur
【mysql索引实现原理】
MySQL面试题——MySQL常见查询
M²BEV: Multi-Camera Joint 3D Detection and Segmentation with Unified Bird’s-Eye View Representation
Loudi Center for Disease Control and Prevention Laboratory Design Concept Description
Inventory of Loudi Agricultural Products Inspection Laboratory Construction Guidelines
Ethernet channel 以太信道
瑞幸「翻身」?恐言之尚早
友邦人寿可观测体系设计与落地