mitmproxy抓包 | Python疑难测试场景mock

往期经典文章回顾:

抓包工具mitmproxy环境配置使用(一)

抓包工具mitmproxy | mitmweb基本用法(二)

mitmproxy抓包 | Python实时生成接口自动化用例

mitmproxy抓包 | Python实时生成接口自动化用例(三)

在实际工作中,经常会遇到前端模块开发完了,后端还没开发完,测试闲的没事干,导致测试介入延迟,为了解决此问题,我们可以采用mitmproxy代理抓包进行mock服务测试,根据接口文档mock不同的响应数据,对前端功能进行测试,提前介入测试,暴露问题,节省项目成本。

 还有一些疑难测试场景,很难手动模拟出来,简单介绍一种,例如:已打卡,button置灰无法再次打卡测试重复提交,小A说:可以快速连点,如果前端做了防重点,还是很难连点出来进行测试的;小B说:可修改数据库打卡状态,这样只能说明他今天没打卡,还可以进行正常打卡的,未达到测试重复提交测试效果;小C说:可以通过接口重复请求进行测试,这样是可以的,但是只是针对后端重复提交进行了测试,还是未达到前端测试的效果;小D说:可以通过模拟网络延迟,这个应该是可以的,因为当你点击签到时,请求发出去了,响应还没有回来,打卡button还未更新,仍显示的亮起可打卡,这时,可以再次发起第2次打卡,测试重复提交。

借助mitmproxy代理抓包工具的mock功能还是很方便,结合简单的python脚本匹配要mock的接口地址,替换成想要设置的响应数据,每次APP

发起请求,会经过mitmproxy代理抓包工具,得到设置好的响应数据,前端对应展示出我们想要的测试场景。

我们以得物APP-打卡话题列表-今天只晒鞋-打卡,案例实战一下,测试场景:打卡成功,再次打卡

未打卡时,打卡话题页面,今天只晒鞋,立即打卡显示亮起可点击

62979aa5cb5289316d252082f67a97e8.png

未打卡时,打卡话题列表接口信息

https://m.dewu.com/sns/v1/tag/clockin-topic-list?newSign=338e7a221b66936aa313763a5c139a42appId:       duapp
brand:       Apple
cookieToken: d41d8cd9|1573201658|1638408681|68e26bc5b040d083
emu:         0
isProxy:     1
isRoot:      0
lastId:      
limit:       20
loginToken:  44462107|1573201658|4bed211ae9d2d5a8
mode:        0
platform:    iPhone
shumeiid:    20210918092735f1e54bce67bb69d503b7fb355c4690cf01d77ce3f35e2132
sign:        a2a9aa440b638aafd8b4ff62671231ed
timestamp:   1638409137400
token:       JLIjsdLjfsdII%3D%7CMTQxODg3MDczNA%3D%3D%7C07aaal32795abdeff41cc9633329932195
userId:      1573201658
uuid:        UUID785a82408e934daf9f9240fb286900ea
v:           4.79.7{"data": {"existOfflineClockin": 0,"go": true,"lastId": "","list": [{"clockInId": "19","containsNum": 1971522,"orderBy": "665","tagDesc": "鞋狗每日打卡!晒晒你的宝贝球鞋\n欢迎分享:球鞋上脚照、入手感受、搭配建议等\n图片、文字符合主题,可获得更多点赞和关注!","tagId": 295,"tagName": "今天只晒鞋","thumb": "https://du.hupucdn.com/Fu1T5EEUemk6sW6210x8O5M7-woi","userContinuousNum": "0","userHistoryNum": 0,"userJoined": "0","userRank": "-","userTodayJoined": "0"},{"clockInId": "47","containsNum": 1594616,"orderBy": "663","tagDesc": "OOTD,来分享你的每日穿搭~","tagId": 9,"tagName": "今天穿什么","thumb": "https://du.hupucdn.com/FtoOBG0AM6e0MYXcEvxq6Rctcbjs","userContinuousNum": "0","userHistoryNum": 0,"userJoined": "0","userRank": "-","userTodayJoined": "0"},{"clockInId": "126","containsNum": 87783,"orderBy": "657","tagDesc": "欢迎分享各类体育比赛视频,送你上首页推荐!","tagId": 267,"tagName": "体育精彩视频分享","thumb": "https://du.hupucdn.com/lghvdJY0hjTdIOHV870o1-l41SHl","userContinuousNum": "0","userHistoryNum": 0,"userJoined": "0","userRank": "-","userTodayJoined": "0"},{"clockInId": "138","containsNum": 83280,"orderBy": "655","tagDesc": "欢迎分享你喜爱的、想推荐的说唱音乐视频!\n建议:清晰无水印、写出作品名称、作者名字、你想推荐的理由\n质量越高的内容,越容易获得更多曝光哦!","tagId": 1360,"tagName": "说唱音乐视频分享","thumb": "https://du.hupucdn.com/Fr1A4aB9BxdLb_RrHZ84WI6Cj8o7","userContinuousNum": "0","userHistoryNum": 0,"userJoined": "0","userRank": "-","userTodayJoined": "0"},{"clockInId": "140","containsNum": 68899,"orderBy": "650","tagDesc": "欢迎分享你喜爱的、想推荐的街舞视频!\n建议:清晰无水印、写出作品名称、作者名字、你想推荐的理由\n质量越高的内容,越容易获得更多曝光哦!","tagId": 247,"tagName": "街舞视频分享","thumb": "https://du.hupucdn.com/FoAfCBfHKIfxvr5pWPjvxvBelfZY","userContinuousNum": "0","userHistoryNum": 0,"userJoined": "0","userRank": "-","userTodayJoined": "0"},{"clockInId": "25","containsNum": 293796,"orderBy": "644","tagDesc": "康康你的自拍照,有机会上首页推荐哦!","tagId": 310,"tagName": "就是爱自拍","thumb": "https://du.hupucdn.com/Fn3LjHqtx1mR1TsJhhIuMzklPzC0","userContinuousNum": "0","userHistoryNum": 0,"userJoined": "0","userRank": "-","userTodayJoined": "0"},{"clockInId": "147","containsNum": 220616,"orderBy": "643","tagDesc": "让我康康仙女都在买啥(⊙_⊙)","tagId": 1595,"tagName": "美妆种草","thumb": "https://du.hupucdn.com/FpeNLkzEWUeckefHu0gxqFKPqvab","userContinuousNum": "0","userHistoryNum": 0,"userJoined": "0","userRank": "-","userTodayJoined": "0"},{"clockInId": "83","containsNum": 1498983,"orderBy": "642","tagDesc": "那些你最喜欢的壁纸,和大家一起分享吧~","tagId": 249,"tagName": "每日一张壁纸","thumb": "https://du.hupucdn.com/Fm5FlcDrKBPvRZr67F-nJKEdaj6r","userContinuousNum": "0","userHistoryNum": 0,"userJoined": "0","userRank": "-","userTodayJoined": "0"},{"clockInId": "15","containsNum": 72869,"orderBy": "640","tagDesc": "不怕车不帅就怕你不发,冲!","tagId": 16,"tagName": "就想晒个车","thumb": "https://du.hupucdn.com/FjFXqQEyo6aAh9MrKQb787m-LBxy","userContinuousNum": "0","userHistoryNum": 0,"userJoined": "0","userRank": "-","userTodayJoined": "0"},{"clockInId": "67","containsNum": 78132,"orderBy": "638","tagDesc": "入手了新玩具?快来晒晒吧!有机会上首页推荐哦!","tagId": 259,"tagName": "晒下新玩具","thumb": "https://du.hupucdn.com/FnKepVPzANQsDvrTiomW7kWZubIs","userContinuousNum": "0","userHistoryNum": 0,"userJoined": "0","userRank": "-","userTodayJoined": "0"},{"clockInId": "3","containsNum": 68547,"orderBy": "636","tagDesc": "来这里,记录你的坚持与汗水!记得每日来打卡哦!","tagId": 311,"tagName": "每日运动打卡","thumb": "https://du.hupucdn.com/FkpHtyz3peiEPM_sB9WpfmGcfpBO","userContinuousNum": "0","userHistoryNum": 0,"userJoined": "0","userRank": "-","userTodayJoined": "0"},{"clockInId": "139","containsNum": 27149,"orderBy": "634","tagDesc": "欢迎分享你喜爱的、想推荐的电音视频!\n建议:清晰无水印、写出作品名称、作者名字、你想推荐的理由\n质量越高的内容,越容易获得更多曝光哦!","tagId": 944,"tagName": "电音视频分享","thumb": "https://du.hupucdn.com/FjoGu5hvULvDfX8obhAh742zsOxi","userContinuousNum": "0","userHistoryNum": 0,"userJoined": "0","userRank": "-","userTodayJoined": "0"},{"clockInId": "142","containsNum": 8309,"orderBy": "632","tagDesc": "板仔集合,秀出你的滑板技能!","tagId": 1154,"tagName": "我的滑板日常","thumb": "https://du.hupucdn.com/Ftx6RZSUqR1uHpmzeoZytO7LtXaA","userContinuousNum": "0","userHistoryNum": 0,"userJoined": "0","userRank": "-","userTodayJoined": "0"},{"clockInId": "9","containsNum": 2733545,"orderBy": "576","tagDesc": "每天都要潮出不一样","tagId": 302,"tagName": "潮流生活打卡","thumb": "https://du.hupucdn.com/FjTjA377QeYZDf9oyKyykaNi8L3w","userContinuousNum": "0","userHistoryNum": 0,"userJoined": "0","userRank": "-","userTodayJoined": "0"},{"clockInId": "125","containsNum": 181923,"orderBy": "574","tagDesc": "趣味视频、日常生活记录视频、开箱视频....分享送你上首页推荐!\n\n","tagId": 1263,"tagName": "每日视频打卡","thumb": "https://du.hupucdn.com/lnFKpWrTBz2N25MdzBU2Yti76vT6","userContinuousNum": "0","userHistoryNum": 0,"userJoined": "0","userRank": "-","userTodayJoined": "0"}]},"env": "cs","log": null,"msg": "成功","status": 200,"timestamp": 0.072869062423706
}

已打卡时,打卡话题列表,今天只晒鞋,立即打卡显示置灰不可点击

e2e822321ed175ea55e51e93d527292d.png

已打卡时,打卡话题列表接口信息:

https://m.dewu.com/sns/v1/tag/clockin-topic-list?newSign=ee05369a4777bee2b6b340a1bba10cfcappId:       duapp
brand:       Apple
cookieToken: d41d8cd9|1573201658|1638408681|68e26bc5b040d083
emu:         0
isProxy:     1
isRoot:      0
lastId:      
limit:       20
loginToken:  44462107|1573201658|4bed211ae9d2d5a8
mode:        0
platform:    iPhone
shumeiid:    20210918092735f1e54bce67bb69d503b7fb355c4690cf01d77ce3f35e2132
sign:        aa6f76720b6f4f7eb8e79c067f369994
timestamp:   1638409518296
token:       JLIjsdLjfsdII%3D%7CMTQxODg3MDczNA%3D%3D%7C07aaal32795abdeff41cc9633329932195
userId:      1573201658{"data": {"existOfflineClockin": 0,"go": true,"lastId": "","list": [{"clockInId": "19","containsNum": 1971527,"orderBy": "665","tagDesc": "鞋狗每日打卡!晒晒你的宝贝球鞋\n欢迎分享:球鞋上脚照、入手感受、搭配建议等\n图片、文字符合主题,可获得更多点赞和关注!","tagId": 295,"tagName": "今天只晒鞋","thumb": "https://du.hupucdn.com/Fu1T5EEUemk6sW6210x8O5M7-woi","userContinuousNum": "1","userHistoryNum": 1,"userJoined": "1","userRank": "99+","userTodayJoined": "1"},{"clockInId": "47","containsNum": 1594621,"orderBy": "663","tagDesc": "OOTD,来分享你的每日穿搭~","tagId": 9,"tagName": "今天穿什么","thumb": "https://du.hupucdn.com/FtoOBG0AM6e0MYXcEvxq6Rctcbjs","userContinuousNum": "0","userHistoryNum": 0,"userJoined": "0","userRank": "-","userTodayJoined": "0"},{"clockInId": "126","containsNum": 87783,"orderBy": "657","tagDesc": "欢迎分享各类体育比赛视频,送你上首页推荐!","tagId": 267,"tagName": "体育精彩视频分享","thumb": "https://du.hupucdn.com/lghvdJY0hjTdIOHV870o1-l41SHl","userContinuousNum": "0","userHistoryNum": 0,"userJoined": "0","userRank": "-","userTodayJoined": "0"},{"clockInId": "138","containsNum": 83280,"orderBy": "655","tagDesc": "欢迎分享你喜爱的、想推荐的说唱音乐视频!\n建议:清晰无水印、写出作品名称、作者名字、你想推荐的理由\n质量越高的内容,越容易获得更多曝光哦!","tagId": 1360,"tagName": "说唱音乐视频分享","thumb": "https://du.hupucdn.com/Fr1A4aB9BxdLb_RrHZ84WI6Cj8o7","userContinuousNum": "0","userHistoryNum": 0,"userJoined": "0","userRank": "-","userTodayJoined": "0"},{"clockInId": "140","containsNum": 68899,"orderBy": "650","tagDesc": "欢迎分享你喜爱的、想推荐的街舞视频!\n建议:清晰无水印、写出作品名称、作者名字、你想推荐的理由\n质量越高的内容,越容易获得更多曝光哦!","tagId": 247,"tagName": "街舞视频分享","thumb": "https://du.hupucdn.com/FoAfCBfHKIfxvr5pWPjvxvBelfZY","userContinuousNum": "0","userHistoryNum": 0,"userJoined": "0","userRank": "-","userTodayJoined": "0"},{"clockInId": "25","containsNum": 293797,"orderBy": "644","tagDesc": "康康你的自拍照,有机会上首页推荐哦!","tagId": 310,"tagName": "就是爱自拍","thumb": "https://du.hupucdn.com/Fn3LjHqtx1mR1TsJhhIuMzklPzC0","userContinuousNum": "0","userHistoryNum": 0,"userJoined": "0","userRank": "-","userTodayJoined": "0"},{"clockInId": "147","containsNum": 220616,"orderBy": "643","tagDesc": "让我康康仙女都在买啥(⊙_⊙)","tagId": 1595,"tagName": "美妆种草","thumb": "https://du.hupucdn.com/FpeNLkzEWUeckefHu0gxqFKPqvab","userContinuousNum": "0","userHistoryNum": 0,"userJoined": "0","userRank": "-","userTodayJoined": "0"},{"clockInId": "83","containsNum": 1498987,"orderBy": "642","tagDesc": "那些你最喜欢的壁纸,和大家一起分享吧~","tagId": 249,"tagName": "每日一张壁纸","thumb": "https://du.hupucdn.com/Fm5FlcDrKBPvRZr67F-nJKEdaj6r","userContinuousNum": "0","userHistoryNum": 0,"userJoined": "0","userRank": "-","userTodayJoined": "0"},{"clockInId": "15","containsNum": 72870,"orderBy": "640","tagDesc": "不怕车不帅就怕你不发,冲!","tagId": 16,"tagName": "就想晒个车","thumb": "https://du.hupucdn.com/FjFXqQEyo6aAh9MrKQb787m-LBxy","userContinuousNum": "0","userHistoryNum": 0,"userJoined": "0","userRank": "-","userTodayJoined": "0"},{"clockInId": "67","containsNum": 78133,"orderBy": "638","tagDesc": "入手了新玩具?快来晒晒吧!有机会上首页推荐哦!","tagId": 259,"tagName": "晒下新玩具","thumb": "https://du.hupucdn.com/FnKepVPzANQsDvrTiomW7kWZubIs","userContinuousNum": "0","userHistoryNum": 0,"userJoined": "0","userRank": "-","userTodayJoined": "0"},{"clockInId": "3","containsNum": 68548,"orderBy": "636","tagDesc": "来这里,记录你的坚持与汗水!记得每日来打卡哦!","tagId": 311,"tagName": "每日运动打卡","thumb": "https://du.hupucdn.com/FkpHtyz3peiEPM_sB9WpfmGcfpBO","userContinuousNum": "0","userHistoryNum": 0,"userJoined": "0","userRank": "-","userTodayJoined": "0"},{"clockInId": "139","containsNum": 27149,"orderBy": "634","tagDesc": "欢迎分享你喜爱的、想推荐的电音视频!\n建议:清晰无水印、写出作品名称、作者名字、你想推荐的理由\n质量越高的内容,越容易获得更多曝光哦!","tagId": 944,"tagName": "电音视频分享","thumb": "https://du.hupucdn.com/FjoGu5hvULvDfX8obhAh742zsOxi","userContinuousNum": "0","userHistoryNum": 0,"userJoined": "0","userRank": "-","userTodayJoined": "0"},{"clockInId": "142","containsNum": 8310,"orderBy": "632","tagDesc": "板仔集合,秀出你的滑板技能!","tagId": 1154,"tagName": "我的滑板日常","thumb": "https://du.hupucdn.com/Ftx6RZSUqR1uHpmzeoZytO7LtXaA","userContinuousNum": "0","userHistoryNum": 0,"userJoined": "0","userRank": "-","userTodayJoined": "0"},{"clockInId": "9","containsNum": 2733550,"orderBy": "576","tagDesc": "每天都要潮出不一样","tagId": 302,"tagName": "潮流生活打卡","thumb": "https://du.hupucdn.com/FjTjA377QeYZDf9oyKyykaNi8L3w","userContinuousNum": "0","userHistoryNum": 0,"userJoined": "0","userRank": "-","userTodayJoined": "0"},{"clockInId": "125","containsNum": 181923,"orderBy": "574","tagDesc": "趣味视频、日常生活记录视频、开箱视频....分享送你上首页推荐!\n\n","tagId": 1263,"tagName": "每日视频打卡","thumb": "https://du.hupucdn.com/lnFKpWrTBz2N25MdzBU2Yti76vT6","userContinuousNum": "0","userHistoryNum": 0,"userJoined": "0","userRank": "-","userTodayJoined": "0"}]},"env": "cs","log": null,"msg": "成功","status": 200,"timestamp": 0.075935125350952
}

Python脚本:

import json, osresponse_data = {"data": {"existOfflineClockin": 0,"go": 'true',"lastId": "","list": [{"clockInId": "19","containsNum": 1971522,"orderBy": "665","tagDesc": "鞋狗每日打卡!晒晒你的宝贝球鞋\n欢迎分享:球鞋上脚照、入手感受、搭配建议等\n图片、文字符合主题,可获得更多点赞和关注!","tagId": 295,"tagName": "今天只晒鞋","thumb": "https://du.hupucdn.com/Fu1T5EEUemk6sW6210x8O5M7-woi","userContinuousNum": "0","userHistoryNum": 0,"userJoined": "0","userRank": "-","userTodayJoined": "0"},{"clockInId": "47","containsNum": 1594616,"orderBy": "663","tagDesc": "OOTD,来分享你的每日穿搭~","tagId": 9,"tagName": "今天穿什么","thumb": "https://du.hupucdn.com/FtoOBG0AM6e0MYXcEvxq6Rctcbjs","userContinuousNum": "0","userHistoryNum": 0,"userJoined": "0","userRank": "-","userTodayJoined": "0"},{"clockInId": "126","containsNum": 87783,"orderBy": "657","tagDesc": "欢迎分享各类体育比赛视频,送你上首页推荐!","tagId": 267,"tagName": "体育精彩视频分享","thumb": "https://du.hupucdn.com/lghvdJY0hjTdIOHV870o1-l41SHl","userContinuousNum": "0","userHistoryNum": 0,"userJoined": "0","userRank": "-","userTodayJoined": "0"},{"clockInId": "138","containsNum": 83280,"orderBy": "655","tagDesc": "欢迎分享你喜爱的、想推荐的说唱音乐视频!\n建议:清晰无水印、写出作品名称、作者名字、你想推荐的理由\n质量越高的内容,越容易获得更多曝光哦!","tagId": 1360,"tagName": "说唱音乐视频分享","thumb": "https://du.hupucdn.com/Fr1A4aB9BxdLb_RrHZ84WI6Cj8o7","userContinuousNum": "0","userHistoryNum": 0,"userJoined": "0","userRank": "-","userTodayJoined": "0"},{"clockInId": "140","containsNum": 68899,"orderBy": "650","tagDesc": "欢迎分享你喜爱的、想推荐的街舞视频!\n建议:清晰无水印、写出作品名称、作者名字、你想推荐的理由\n质量越高的内容,越容易获得更多曝光哦!","tagId": 247,"tagName": "街舞视频分享","thumb": "https://du.hupucdn.com/FoAfCBfHKIfxvr5pWPjvxvBelfZY","userContinuousNum": "0","userHistoryNum": 0,"userJoined": "0","userRank": "-","userTodayJoined": "0"},{"clockInId": "25","containsNum": 293796,"orderBy": "644","tagDesc": "康康你的自拍照,有机会上首页推荐哦!","tagId": 310,"tagName": "就是爱自拍","thumb": "https://du.hupucdn.com/Fn3LjHqtx1mR1TsJhhIuMzklPzC0","userContinuousNum": "0","userHistoryNum": 0,"userJoined": "0","userRank": "-","userTodayJoined": "0"},{"clockInId": "147","containsNum": 220616,"orderBy": "643","tagDesc": "让我康康仙女都在买啥(⊙_⊙)","tagId": 1595,"tagName": "美妆种草","thumb": "https://du.hupucdn.com/FpeNLkzEWUeckefHu0gxqFKPqvab","userContinuousNum": "0","userHistoryNum": 0,"userJoined": "0","userRank": "-","userTodayJoined": "0"},{"clockInId": "83","containsNum": 1498983,"orderBy": "642","tagDesc": "那些你最喜欢的壁纸,和大家一起分享吧~","tagId": 249,"tagName": "每日一张壁纸","thumb": "https://du.hupucdn.com/Fm5FlcDrKBPvRZr67F-nJKEdaj6r","userContinuousNum": "0","userHistoryNum": 0,"userJoined": "0","userRank": "-","userTodayJoined": "0"},{"clockInId": "15","containsNum": 72869,"orderBy": "640","tagDesc": "不怕车不帅就怕你不发,冲!","tagId": 16,"tagName": "就想晒个车","thumb": "https://du.hupucdn.com/FjFXqQEyo6aAh9MrKQb787m-LBxy","userContinuousNum": "0","userHistoryNum": 0,"userJoined": "0","userRank": "-","userTodayJoined": "0"},{"clockInId": "67","containsNum": 78132,"orderBy": "638","tagDesc": "入手了新玩具?快来晒晒吧!有机会上首页推荐哦!","tagId": 259,"tagName": "晒下新玩具","thumb": "https://du.hupucdn.com/FnKepVPzANQsDvrTiomW7kWZubIs","userContinuousNum": "0","userHistoryNum": 0,"userJoined": "0","userRank": "-","userTodayJoined": "0"},{"clockInId": "3","containsNum": 68547,"orderBy": "636","tagDesc": "来这里,记录你的坚持与汗水!记得每日来打卡哦!","tagId": 311,"tagName": "每日运动打卡","thumb": "https://du.hupucdn.com/FkpHtyz3peiEPM_sB9WpfmGcfpBO","userContinuousNum": "0","userHistoryNum": 0,"userJoined": "0","userRank": "-","userTodayJoined": "0"},{"clockInId": "139","containsNum": 27149,"orderBy": "634","tagDesc": "欢迎分享你喜爱的、想推荐的电音视频!\n建议:清晰无水印、写出作品名称、作者名字、你想推荐的理由\n质量越高的内容,越容易获得更多曝光哦!","tagId": 944,"tagName": "电音视频分享","thumb": "https://du.hupucdn.com/FjoGu5hvULvDfX8obhAh742zsOxi","userContinuousNum": "0","userHistoryNum": 0,"userJoined": "0","userRank": "-","userTodayJoined": "0"},{"clockInId": "142","containsNum": 8309,"orderBy": "632","tagDesc": "板仔集合,秀出你的滑板技能!","tagId": 1154,"tagName": "我的滑板日常","thumb": "https://du.hupucdn.com/Ftx6RZSUqR1uHpmzeoZytO7LtXaA","userContinuousNum": "0","userHistoryNum": 0,"userJoined": "0","userRank": "-","userTodayJoined": "0"},{"clockInId": "9","containsNum": 2733545,"orderBy": "576","tagDesc": "每天都要潮出不一样","tagId": 302,"tagName": "潮流生活打卡","thumb": "https://du.hupucdn.com/FjTjA377QeYZDf9oyKyykaNi8L3w","userContinuousNum": "0","userHistoryNum": 0,"userJoined": "0","userRank": "-","userTodayJoined": "0"},{"clockInId": "125","containsNum": 181923,"orderBy": "574","tagDesc": "趣味视频、日常生活记录视频、开箱视频....分享送你上首页推荐!\n\n","tagId": 1263,"tagName": "每日视频打卡","thumb": "https://du.hupucdn.com/lnFKpWrTBz2N25MdzBU2Yti76vT6","userContinuousNum": "0","userHistoryNum": 0,"userJoined": "0","userRank": "-","userTodayJoined": "0"}]},"env": "cs","log": 'null',"msg": "成功","status": 200,"timestamp": 0.072869062423706
}class ModifyResponse:def response(self, flow):# 拦截指定的urlif flow.request.url.startswith('https://m.dewu.com/sns/v1/tag/clockin-topic-list'):# 设置响应据flow.response.set_text ( json.dumps(response_data) )addons = [ModifyResponse()
]

启动mitmproxy代理并启动python脚本实时监控

cmd下执行

mitmweb -p 8989 -s C:\Users\xia\Desktop\AutoTest\srzp_api_test\main\test.py

edf02bf82de2e03783971b344d74f1f3.png

发现请求url中有接口地址:https://m.dewu.com/sns/v1/tag/clockin-topic-list 把未打卡时的响应数据返给APP,APP端呈现出立即打卡亮起状态,可操作再次立即打卡,达到要测试的效果。

当然也可以更改响应数据的打卡状态为非0非1,测似默认状态下button是怎么展示的?接口响应数据还没回来时,怎么展示的?等等

067056ec439d513efc8dc1e9ee5c59a6.png

f03c8f38ad532241a94b20e68d079b10.png

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/568140.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

opencv图像分割2-GMM

GMM随机数分类&#xff1a; #include<opencv2\opencv.hpp> #include<iostream> using namespace cv; using namespace std; using namespace cv::ml; int main() {Mat imgMat::zeros(500, 500, CV_8UC3);RNG rng(12345);Scalar colorTab[] {Scalar(0,0,255),Scal…

mitmproxy抓包 | Python疑难测试场景mock实战(四)

往期经典文章回顾&#xff1a;抓包工具mitmproxy环境配置使用&#xff08;一&#xff09;抓包工具mitmproxy | mitmweb基本用法&#xff08;二&#xff09;mitmproxy抓包 | Python实时生成接口自动化用例mitmproxy抓包 | Python实时生成接口自动化用例&#xff08;三&#xff0…

mitmproxy抓包 | Python篡改请求参数实战(五)

抓包工具mitmproxy环境配置使用&#xff08;一&#xff09;抓包工具mitmproxy | mitmweb基本用法&#xff08;二&#xff09;mitmproxy抓包 | Python实时生成接口自动化用例&#xff08;三&#xff09;mitmproxy抓包 | Python实时生成接口自动化用例mitmproxy抓包 | Python疑难…

数据结构-链表1-顺序存储

DynamicArray.h #ifndef DYNAMIC_ARRAY_H #define DYNAMIC_ARRAY_H #define _CRT_SECURE_NO_WARNINGS #include<stdlib.h> #include<stdio.h> #include<string.h>//动态数组结构体 typedef struct DYNAMICARRAY {int* pAddr; //具体存放数据的地址int size…

全网都在用的超全【面试刷题小程序】,最新版激活教程

前几天&#xff0c;我的一个粉丝留言给我说&#xff0c;他在面试美团的自动化测试岗的时候&#xff0c;不幸挂掉了。越想越觉得可惜&#xff0c;回想面试经过&#xff0c;好好总结了几个点&#xff0c;发现面试没过的主要原因是在几个关键的问题没有给到面试官想要的答案。从而…

数据结构-链表2-链式存储

LinkList.h #ifndef LINKLIST_H #define LINKLIST_H #define _CRT_SECURE_NO_WARNINGS #include<stdlib.h> #include<stdio.h> #include<string.h>//链表结点 typedef struct LINKNODE {void* data; //无类型指针&#xff0c;指向任何类型的数据struct LIN…

字节内部自动化测试培训资料,明年涨薪用得上

今天是12月27日&#xff0c;2021年还剩下最后4天。昨晚我收到一位粉丝朋友的涨薪喜讯&#xff0c;他踩着2021的尾巴&#xff0c;成功跳进广州海珠的互联网巨头&#xff0c;涨薪幅度达284%。其实每年的年末&#xff0c;圈子里的朋友都特别忙&#xff0c;大家都在为来年跳槽做准备…

数据结构-链表3-循环链表

LinkList.h #ifndef LINKLIST_H #define LINKLIST_H #define _CRT_SECURE_NO_WARNINGS #include<stdlib.h> #include<stdio.h> #include<string.h>//链表小结点 typedef struct CIRCLELINKNODE {struct LinkNode *next; }CircleLinkNode;//链表结构体 type…

探索篇 | 接口字段容错测试(三)

往期关联文章&#xff1a;探索测试 | 新奇深层测试策略之案例剖析&#xff08;一&#xff09;探索篇 | 新奇测试策略剖析&#xff0c;大家都觉得多此一举(二)探索篇|越权测试策略之案例剖析&#xff08;一&#xff09;重磅福利 | 全网唯一,多年踩坑经验&#xff0c;探索测试策略…

数据结构-链表4-企业链表

LinkList.h #ifndef LINKLIST_H #define LINKLIST_H#include<stdio.h> #include<stdlib.h> //链表结点 typedef struct LINKNODE {struct LINKNODE *next; }LinkNode;//链表 typedef struct LINKLIST{LinkNode head; //放在第一个&#xff0c;防止有偏移量.//不…

全网都在看的Jmeter精选原创文章

点击上方“蓝字”&#xff0c;轻松关注我们Jmeter 原创合集‍‍‍‍‍‍‍1、【Jmeter篇】Linux环境下安装部署运行Jmeter2、Jmeter跨线程组传递参数3、Jmeter中JDBC Connection Configuration实现MySQL JDBC Request数据库处理4、Jmeter JDBC Request执行多条SQL语句5、Jmeter…

opencv之namedWindow,imshow出现两个窗口

初学opencv&#xff0c;代码如下&#xff0c;按理来说结果应该是&#xff1a;一个cmd命令行窗口&#xff0c;一个显示照片的窗口 #include<opencv2\opencv.hpp> #include<iostream> using namespace cv; using namespace std; int main() {const char* win_name …

全网都在看的Fiddler、mitmproxy抓包秘籍,花钱都买不到

点击上方“蓝字”&#xff0c;轻松关注我们Fiddler、mitmproxy、Stream抓包工具原创集合1、Fiddler抓取APP请求&#xff08;环境搭建&#xff09;之mama再也不用担心抓不到包了2、Fiddler抓包神器带你遨游网络&#xff0c;叱咤风云&#xff0c;为所欲为3、Fiddler抓包 | 竟然有…

无法打开文件“python35_d.lib”

在windows10安装opencv时&#xff0c;执行cmake之后&#xff0c;用vs2015打开工程&#xff0c;在debug下&#xff0c;生成INSTALL会出现 错误 1 error LNK1104: 无法打开文件“python35_d.lib” 。 转自 http://blog.csdn.net/Chris_zhangrx/article/details/78947526 在用…

缺陷定位 | 如何精准效率分析推测BUG定位(二)

点击上方“蓝字”&#xff0c;轻松关注我们明天就是除夕了&#xff0c;很多人都回到了老家&#xff0c;吃上了妈妈做的饭菜&#xff0c;这时候应该是最幸福的时刻&#xff0c;我也用年前上班仅剩的几小时把 缺陷定位&#xff08;二&#xff09;分享给大家&#xff0c;希望大家能…

VS2015+cmake3.8+opencv3.2+opencv-contrib3.2编译及配置步骤

一、下载以下文件并解压和安装cmake。并在同目录下新建文件夹mybuild 文件1 opencv-3.2.0-vc14.exe 文件2 opencv_contrib-3.2.0.zip 文件3 cmake-3.8.0-win64-x64.msi 二、打开cmake&#xff0c;并填写路径 .cmake第一行输入的是opencv的源码即opencv的source文件&…

缺陷定位 | 分析推理定位BUG案例(三)

往期关联文章&#xff1a;缺陷定位 | 测试发现了Bug&#xff0c;还要分析定位Bug&#xff1f;&#xff08;一&#xff09;缺陷定位 | 如何精准效率分析推测BUG定位&#xff08;二&#xff09;运营反馈&#xff0c;生产环境&#xff0c;WEB端管理后台&#xff0c;岗位审核详情&a…

数据结构-栈1-顺序存储

LinkList.h: #include<stdlib.h> #include<stdio.h> #include<string.h> #define MAX_SIZE 1024 #define TRUE 1 #define FALSE 0typedef struct LINKLIST {void* data[MAX_SIZE];int size;}LinkList;//初始化 LinkList* Init_linkList();//压入元素 void Pu…

构建测试的体系化思维(基础篇)

读完需要22分钟速读仅需 8 分钟之前写过一篇文章《神圣的QA》&#xff0c;是面向想从事 QA 工作的毕业生同学的&#xff0c;文中有讲到 QA 的五个基本职责&#xff1a;理解和澄清业务需求制定策略并设计测试实现和执行测试缺陷管理与分析质量反馈与风险识别最近有朋友希望我能分…

数据结构-栈2-链式存储

LinkList.h #include<stdlib.h> #include<stdio.h> #include<string.h> #define MAX_SIZE 1024 #define TRUE 1 #define FALSE 0//链表结点--存储下一个结点指针 typedef struct LINKNODE {struct LINKNODE *next; }LinkNode;//链表--保存头结点,和链表长度…