如何通过篡改http的返回值来模拟特定场景

最近接到一个需求,需要同时模拟20个司机出现在一个区域内,查看此时拖动地图时,我们的打车软件是否会出现地图卡顿等现象。

那么此时,如何能够模拟出20个司机出现在一个区域内呢?

方法有以下几种

1、找20台手机,同时登陆20个司机账号。

优点:数据完全真实

缺点:需要同时使用20台手机。

2、调用接口,输入司机ID与上线的经纬度

优点:完全模拟真实场景,数据也是真实的数据

缺点:需要对这个流程中的每个接口,如登陆,上线等模块了解清晰,并且事后要做下线处理,否则会对正常派单产生影响。

3、直接修改app所查询的接口返回值

优点:只需修该返回值,无需修该其他

缺点:只能模拟司机车辆图标出现,而这些司机实际是不存在的

解决方案列了出来,那我们应该选择哪个呢?

这首先就要看测试点了。我们的测试点是在乘客端的页面查看20辆车同时出现的情况

那么我们的关注点是只要车辆图标出现,随后移动地图是否卡顿。而不是后台派单是否正确

因此我们的关注点是车辆图标。

而乘客端的司机图标是怎么出现的?

他是通过一个查询附近司机的接口来画图的。

那这个接口的返回值是什么,我们只要修改返回值,给app端造成返回附近有20辆车即可。

所以我们选择方法三

通过与开发沟通,我们发现我们只要修改下经纬度与司机编号,即可。

 

{
“lt”: 30.192,
“lg”: 120.152,
“id”: 3,
“dir”: 15.0
}

而司机编号在这里是不做校验的,只要司机编号不重复即可。

因此我们只要对查询附近司机的接口做返回值替换即可。

那么 how?

首先我们把修改后的返回值保存到本地,命名为x.json

此处x.json内容如下所示:

{
“code”: 0,
“data”: {
“drivers”: [{
“lt”: 30.190,
“lg”: 120.150,
“id”: 1,
“dir”: -1.0
}, {
“lt”: 30.191,
“lg”: 120.151,
“id”: 2,
“dir”: 10.0
},
{
“lt”: 30.192,
“lg”: 120.152,
“id”: 3,
“dir”: 15.0
},
{
“lt”: 30.193,
“lg”: 120.153,
“id”: 4,
“dir”: 20.0
},
{
“lt”: 30.194,
“lg”: 120.154,
“id”: 5,
“dir”: 25.0
},
{
“lt”: 30.195,
“lg”: 120.155,
“id”: 6,
“dir”: 30.0
},{
“lt”: 30.196,
“lg”: 120.156,
“id”: 7,
“dir”: 40.0
},{
“lt”: 30.197,
“lg”: 120.157,
“id”: 8,
“dir”: 45.0
},{
“lt”: 30.197,
“lg”: 120.157,
“id”: 9,
“dir”: 50
},{
“lt”: 30.198,
“lg”: 120.158,
“id”: 10,
“dir”: 60.0
},{
“lt”: 30.199,
“lg”: 120.159,
“id”: 11,
“dir”: 70.0
},{
“lt”: 30.200,
“lg”: 120.160,
“id”: 12,
“dir”: 80.0
},{
“lt”: 30.201,
“lg”: 120.161,
“id”: 13,
“dir”: 90.0
},{
“lt”: 30.202,
“lg”: 120.162,
“id”: 14,
“dir”: 100.0
},{
“lt”: 30.204,
“lg”: 120.164,
“id”: 15,
“dir”: 40.0
},{
“lt”: 30.203,
“lg”: 120.163,
“id”: 16,
“dir”: 40.0
},{
“lt”: 30.204,
“lg”: 120.164,
“id”: 17,
“dir”: 40.0
},{
“lt”: 30.189,
“lg”: 120.149,
“id”: 18,
“dir”: 40.0
},{
“lt”: 30.188,
“lg”: 120.148,
“id”: 19,
“dir”: 40.0
},{
“lt”: 30.187,
“lg”: 120.147,
“id”: 20,
“dir”: 40.0
}] },
“message”: “成功”
}

以下前提是建立在你已经调通了charles 能正常抓包的情况下

我们打开charles

点击本地映射 map local

点击此处随后点击添加

 

随后修改请求 这些请求都可以通过抓包来获取

随后把map to指向刚才的json文件

点击保存后 结果如下图所示

就会出现20辆车同时存在的情况了

About the author: tangtao

137 comments to “如何通过篡改http的返回值来模拟特定场景”

You can leave a reply or Trackback this post.

  1. http://xxxporndays.com/ - 2019年9月15日 at 08:36 Reply

    Enjoyed every bit of your blog.Really thank you! Really Great.

  2. wand massager - 2019年9月14日 at 21:35 Reply

    Im thankful for the article post.Really thank you! Keep writing.

  3. hop dung dong ho co - 2019年9月13日 at 21:39 Reply

    It as very straightforward to find out any matter on net as compared to books, as I found this article at this web page.

  4. sofa go - 2019年9月13日 at 21:28 Reply

    Very good article.Thanks Again. Really Great.

  5. photo emoji editor download for pc - 2019年9月13日 at 14:18 Reply

    Muchos Gracias for your article post.Thanks Again. Fantastic.

  6. discount watches - 2019年9月13日 at 04:19 Reply

    We appreciate, result in I ran across what exactly I had been seeking. You could have wrapped up my own Some evening extended quest! Our god Bless you man. Use a fantastic time. Ok bye

  7. SEO Case Study - 2019年9月13日 at 00:56 Reply

    Thank you ever so for you post.Really thank you! Much obliged.

  8. 9anime app free download - 2019年9月12日 at 21:07 Reply

    Thanks again for the article post.Thanks Again. Much obliged.

  9. buttonbass apk download for pc - 2019年9月12日 at 16:57 Reply

    I think this is a real great blog article. Keep writing.

  10. chatib apk download for pc - 2019年9月12日 at 10:28 Reply

    Nice blog here! Also your website loads up very fast! What web host are you using? Can I get your affiliate link to your host? I wish my web site loaded up as quickly as yours lol

  11. flenix app download for pc - 2019年9月12日 at 07:16 Reply

    This is one awesome blog post.Really thank you! Cool.

  12. buy cvv - 2019年9月11日 at 19:54 Reply

    Thanks for the article post.Really thank you!

  13. legit carding forums - 2019年9月11日 at 16:40 Reply

    There is certainly a great deal to find out about this topic. I really like all the points you ave made.

  14. Best Ukulele Rewviews - 2019年9月11日 at 15:47 Reply

    three triple credit report How hard is it to write a wordpress theme to fit into an existing site?

  15. princess bouncy castle with slide hire - 2019年9月9日 at 07:20 Reply

    Appreciate you sharing, great article. Really Cool.

  16. https://www.signinsupport.net/ - 2019年9月8日 at 05:53 Reply

    I really enjoy the blog article. Want more.

  17. Home Tutor Patna - 2019年9月7日 at 03:34 Reply

    I think this is a real great blog post.Thanks Again. Much obliged.

  18. best kegel balls - 2019年9月5日 at 20:51 Reply

    Great blog.Really thank you! Really Cool.

  19. domanda di visto - 2019年9月5日 at 09:18 Reply

    Whats up this is kind of of off topic but I was wondering if blogs use WYSIWYG
    editors or if you have to manually code with
    HTML. I’m starting a blog soon but have no coding experience so
    I wanted to get advice from someone with experience.
    Any help would be greatly appreciated!

  20. steel cock ring - 2019年9月5日 at 08:02 Reply

    I am so grateful for your article post.Really thank you! Much obliged.

  21. adam and eve shop - 2019年9月2日 at 10:44 Reply

    Say, you got a nice blog post. Much obliged.

  22. cyberskin dildo - 2019年9月1日 at 20:30 Reply

    Thanks for sharing, this is a fantastic blog.Thanks Again. Really Cool.

  23. HAWA 186 - 2019年9月1日 at 11:39 Reply

    I value the article.Much thanks again. Will read on…

  24. TBF Financial reviews - 2019年8月31日 at 11:20 Reply

    Really enjoyed this blog article.Much thanks again. Will read on…

  25. denver auto injury attorney - 2019年8月30日 at 11:47 Reply

    Very good article.Really looking forward to read more. Fantastic.

  26. bouncy castle hire company lewisham - 2019年8月30日 at 04:29 Reply

    I truly appreciate this blog.Really looking forward to read more. Cool.

  27. cheap bouncy castle hire - 2019年8月29日 at 20:33 Reply

    Im thankful for the blog post.Thanks Again. Much obliged.

  28. Bennett Oliveria - 2019年8月29日 at 02:55 Reply

    Youre so cool! I dont suppose Ive read anything this way just before. So nice to seek out somebody with a few original thoughts on this subject. realy thanks for beginning this up. this web site is one thing that is needed on the net, someone with some originality. helpful project for bringing something totally new towards the web!

  29. 50 percent off adameve - 2019年8月27日 at 07:20 Reply

    Very good blog.Thanks Again. Keep writing.

  30. บอลเด็ดล้มโต๊ะ - 2019年8月26日 at 09:37 Reply

    Thanks a lot for the blog post. Will read on…

  31. JUY 978 - 2019年8月25日 at 12:51 Reply

    I appreciate you sharing this blog. Keep writing.

Comment pages

Leave a Reply

Your email address will not be published.