用Puppeteer拦截页面上的XHR请求并返回模拟响应的最佳方法 [英] Best way to intercept XHR request on page with Puppeteer and return mock response

查看:153
本文介绍了用Puppeteer拦截页面上的XHR请求并返回模拟响应的最佳方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要能够在加载了 Puppeteer 的页面上拦截XHR请求,并按顺序返回模拟响应为我的Web应用组织无尽的测试.最好的方法是什么?

I need to be able to intercept XHR requests on page loaded with Puppeteer and return mock responses in order to organize backendless testing for my web app. What's the best way to do this?

推荐答案

好.在最新的人偶中,它提供了 request.respond()方法来处理这种情况.

Well. In the newest puppeteer,it provide the request.respond() method to handle this situation.

这篇关于用Puppeteer拦截页面上的XHR请求并返回模拟响应的最佳方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆