模拟网页发出的Ajax调用的响应(网络测试) [英] Simulating a response for an ajax call that a web page makes (web-testing)
问题描述
如何测试Web应用是否已成功从一个错误的后端API退回到了辅助旧式API服务?
Firebug,Chrome或Fiddler可以做到吗?
如何设置我的客户端以将对ajax调用的错误响应返回到某个URL模式?
How can I test that a web app successfully falls back from one faulty back-end API to a secondary legacy API service?
Could Firebug or Chrome, or Fiddler do it?
How can I setup my client to return error responses for ajax calls to a certain URL pattern?
- 使用HTTPS.
- 我无法控制服务器端.
- 我只想错误地执行某些ajax调用,其余的应该可以正常工作(拉网络插头不是一种选择).
推荐答案
是的,Fiddler可以轻松地做到这一点.在Fiddler中,点击 AutoResponder 标签.创建一个新规则,指定所需的行为.例如:
Yes, Fiddler can do this easily. In Fiddler, click the AutoResponder tab. Create a new rule that specifies the behavior you want. For instance:
如果请求匹配:webdbg.com/test/Service1
然后回应:*drop
If request matches: webdbg.com/test/Service1
Then respond with: *drop
如果Fiddler曾经收到过对指定URL的请求,它将立即关闭连接.或者,您可以将响应操作设置为返回HTTP/5xx错误,或使用*reset
进行TCP/IP重置连接.
If Fiddler ever gets a request for the specified URL, it will immediately close the connection. Or you could set the response action to return a HTTP/5xx error, or use *reset
to TCP/IP RESET the connection.
请参见 http://www.telerik.com/automated-testing-tools/blog/13-02-15/testing-html5-appcache-with-fiddler.aspx 了解更多详细信息.
See http://www.telerik.com/automated-testing-tools/blog/13-02-15/testing-html5-appcache-with-fiddler.aspx for more details.
这篇关于模拟网页发出的Ajax调用的响应(网络测试)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!