当前位置:网站首页>How to use mitmproxy to get data return in automated testing?
How to use mitmproxy to get data return in automated testing?
2022-07-24 00:43:00 【TEST_ Two black】
Background introduction
When we are at the interface or UI In automation projects , This phenomenon often occurs —— It's obviously a normal request , But can't get the desired data return .
such as :
scene A: Pages are dynamic data , The data obtained by entering the page for the first time , It is completely different from the data obtained next time you enter the page .
scene B: Page data has display restrictions , Some modules of the page or the entire page data are only displayed 3 Time , And the server returns the control .
What should we do at this time ?
If it is a manual test , We can use it directly Charles、Fiddler To simulate , After all, agent software can basically solve most of the testing needs .
What if it's in an automation project ? If you still use agent software —— In fact, it's not completely impossible , But we have better ways to practice .
That is to use MitmProxy Act as a forward proxy to intercept requests and return data .
How to use MitmProxy As a forward agent
Realization Maplocal
MitmProxy It's a tripartite library , We can regard it as Charles To use .
Here to achieve Maplocal Function description :
(1)Maplocal function , The simple understanding is when specific requests , Return specific data .
For example, request "www.baidu.com", Normal should return to :

But we modify the returned data , As long as there is "www.baidu.com" Please come here , Just let it return automatically :
This is the most basic maplocal Case study .
(2) stay MitmProxy How to realize Maplocal What about function? ?
Here we use get Request the implementation to explain :
get.json The configuration file , Record all that need to be intercepted here get request :
MitmProxy Script :

In the executed script ( Like local shell or Other implemented py Script ):
After starting the script , Connect MitmProxy All requests from devices will be monitored by scripts .
If appear "www.baidu.com" Request , It will come to get.json Find the corresponding in json, Automatically return to the device .
such , It realizes the simplest maplocal.
Of course, based on the current MitmProxy Script , We can also expand some functions .
For example, for the interface type get or post request , For request parameter type json or x-www-form-urlencoded, Can be extended more .
Send learning resources to

These materials , For doing 【 software test 】 It should be the most comprehensive and complete war preparation warehouse for advanced friends , This warehouse also accompanied me through the most difficult journey , I hope it can help you ! Everything should be done as soon as possible , Especially in the technology industry , We must improve our technical skills . I hope that's helpful …….
边栏推荐
- 入职3个月的测试员面临转正,领导:1年工作经验包装成5年,试用期淘汰
- Gbase 8C session information function (I)
- Gbase 8C session information function (II)
- Bean Validation自定义容器验证篇----06
- Gbase 8C mode visibility query function (2)
- Network system experiment: solve the problem of Ping failure
- 数仓数据指标和标签体系区别
- A good habit to develop when writing SQL
- Flutter | firstwhere error reporting
- MySQL's heart index
猜你喜欢

MariaDB database upgrade version

postman测试接口在URL配置正确的情况下出现404或者500错误

Docker pulls the redis image and runs it
CA digital certificate
![[video game training] non contact object size and shape measurement 2020 video game G](/img/b7/d70a702e52062e38176b589eb15415.jpg)
[video game training] non contact object size and shape measurement 2020 video game G

PostgreSQL snapshot optimization globalvis new system analysis (greatly enhanced performance)

北峰通信亮相中国(厦门)应急展|智能化通信手段强势吸睛!

How can dbcontext support the migration of different databases in efcore advanced SaaS system

如何在自动化测试中使用MitmProxy获取数据返回?

Overview of data model design method
随机推荐
Summary of polynomial commitment schemes
Redis cluster hash sharding algorithm (slot location algorithm)
SAP 实施项目中涉及到编程方式操作 Excel 的几种场景介绍
Easy gene | target gene DNA methylation sequencing (target BS)
[video game training] non contact object size and shape measurement 2020 video game G
Classic example of C language - loan balance
Redis master-slave synchronization mechanism
MySQL's heart index
GBase 8c 访问权限查询函数(二)
Redis data structure
Detailed overview of data standards -2022
High number_ Chapter 2 differential calculus of multivariate functions__ Geometric application of partial derivatives_ Tangent and normal plane of space curve
Implementation of singleton mode in C #
The most basic code interpretation of C language
多源文件方式去访问全局变量的方式(extern用法)
Gbase 8C system table information function (II)
Blockbuster | certik: Web3.0 industry safety report release in the second quarter of 2022 (PDF download link attached)
win10下基于anaconda的detectron2安装
Flutter | specifies the type of page return value
Expérience du système réseau: résoudre les problèmes de ping