Sel*_*wyn 6 proxy post selenium
您好,尝试使用browsermob proxy + selenium测试框架捕获HTTP POST请求中的实际POST数据.所以基本上我正在运行使用selenium的自动化测试,我想在测试期间捕获键/值对和HTTP POST请求的实际POST数据.使用以下逻辑,我只能捕获POST标头的键/值对,但不能捕获实际的POST数据(也就是表单字段id值).有没有办法实际捕获POSTDATA(如嗅探应用程序,如在Firefox中篡改/实时标题)?
ProxyServer proxyServer = null;
proxyServer = new ProxyServer(9101);
proxyServer.start();
proxyServer.setCaptureContent(true);
proxyServer.setCaptureHeaders(true);
Proxy proxy = proxyServer.seleniumProxy();
proxy.setHttpProxy("localhost:9101");
//selenium test config code, omitted for brevity
proxyServer.addRequestInterceptor(new HttpRequestInterceptor() {
public void process(HttpRequest request, HttpContext context) throws HttpException, IOException {
Header[] headers = request.getAllHeaders();
System.out.println("\nRequest Headers\n\n");
for(Header h : headers) {
System.out.println("Key: " + h.getName() + " | Value: " + h.getValue());
}
}
});
Run Code Online (Sandbox Code Playgroud)
我读到但无法开始工作的另一种方法是将browsermob代理服务器中的以下标志配置为true:
proxyServer.setCaptureContent(true);
proxyServer.setCaptureHeaders(true);
Run Code Online (Sandbox Code Playgroud)
然后输出实际的HAR文件:
Har har = proxyServer.getHar();
Date date = new Date();
har.writeTo(new File("c:\\tmp\\har_" + date.getTime()));
Run Code Online (Sandbox Code Playgroud)
要查看键/值对,POST数据和响应的实际内容......但是当我解析HAR文件时...我只能再次看到POST标题的键/值对...没有POST数据. ..没有回应内容.我只对实际的POST数据感兴趣.
| 归档时间: |
|
| 查看次数: |
8298 次 |
| 最近记录: |