代码控如何实现配置fiddler

时间:2023-03-09 02:10:18
代码控如何实现配置fiddler

很多小哥哥总觉得测试点点点很low,总想码代码。那么fiddler除了一些手动设置外,还可以进行丰富的代码编写,用以完成任务。

打开fiddler,工具栏选择Rules->Customize Rules

代码控如何实现配置fiddler

没用过的可能有点陌生,实际上和junit很类似

代码控如何实现配置fiddler

给出一段示例:修改fiddler捕获js脚本文件的颜色(FiddlerScript属于fiddler的高级编程了)

static function OnBeforeRequest(oSession: Session) {
// Sample Rule: Color ASPX requests in RED
// if (oSession.uriContains(".aspx")) { oSession["ui-color"] = "red"; } // Sample Rule: Flag POSTs to fiddler2.com in italics
// if (oSession.HostnameIs("www.fiddler2.com") && oSession.HTTPMethodIs("POST")) { oSession["ui-italic"] = "yup"; } // Sample Rule: Break requests for URLs containing "/sandbox/"
// if (oSession.uriContains("/sandbox/")) {
// oSession.oFlags["x-breakrequest"] = "yup"; // Existence of the x-breakrequest flag creates a breakpoint; the "yup" value is unimportant.
// }
if (oSession.url.IndexOf(".js")>-){
oSession["ui-color"] = "orange";
}
}

实际运行效果

代码控如何实现配置fiddler

小哥哥们,个性、便捷、丰富的测试工具期待你的使用。