当前位置:网站首页>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 object
method: 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.
边栏推荐
- 神经网络学习-正则化
- 跨域的五种解决方案
- Loudi Center for Disease Control and Prevention Laboratory Design Concept Description
- 友邦人寿可观测体系设计与落地
- 递归递推之计算组合数
- Redis上云迁移实践
- 10 款更先进的开源命令行工具
- “68道 Redis+168道 MySQL”精品面试题(带解析)
- LeetCode medium topic search of two-dimensional matrix
- Efficient and Robust 2D-to-BEV Representation Learning via Geometry-guided Kernel Transformer 论文笔记
猜你喜欢
Wirshark common operations and tcp three-way handshake process example analysis
2022-08-09:以下go语言代码输出什么?A:否,会 panic;B:是,能正确运行;C:不清楚,看投票结果。 package main import ( “fmt“ “syn
LeetCode中等题之搜索二维矩阵
mSystems | Zhongnong Wang Jie Group Reveals the Mechanisms Affecting Soil "Plastic Interstitial" Microbial Communities
Jenkins修改端口号, jenkins容器修改默认端口号
表中存在多个索引问题? - 聚集索引,回表,覆盖索引
ArcMAP出现-15的问题无法访问[Provide your license server administrator with the following information:Err-15]
【学习笔记】Redis的持久化
kubernetes介绍
Detailed explanation of es6-promise object
随机推荐
YTU 2295: KMP模式匹配 一(串)
11+ chrome高级调试技巧,学会效率直接提升666%
iTextSharp 使用详解
漏洞管理计划的未来趋势
协程与任务
2022 Recruitment Notice for Academician Zhao Guoping Group of Shenzhen Institute of Advanced Technology, Chinese Academy of Sciences
10 款更先进的开源命令行工具
Reversing words in a string in LeetCode
娄底妆品实验室建设规划构思
Mysql—— 内连接、左连接、右连接以及全连接查询
Nanodlp v2.2/v3.0 light curing circuit board, connection method of mechanical switch/photoelectric switch/proximity switch and system state level setting
用低代码驱动IT现代化
啥?他一个人写了个价值100万的软件,却用来开源了!
【黑马早报】雷军称低谷期曾想转行开酒吧;拜登正式签署芯片法案;软银二季度巨亏230亿美元;北京市消协约谈每日优鲜...
M²BEV: Multi-Camera Joint 3D Detection and Segmentation with Unified Bird’s-Eye View Representation
递归递推之递归的函数
「网络架构」网络代理第一部分: 代理概述
可视化服务编排在金融APP中的实践
想问下大佬们 ,cdc oracle初始化一张300万的表任务运行着后面就这个错 怎么解决哇
【iOS】面试整理