안녕하세요, browsermob proxy + selenium 테스트 프레임 워크를 사용하여 HTTP POST 요청에서 실제 POST 데이터를 캡처하려고합니다. 그래서 기본적으로 셀렌을 사용하는 자동 테스트를 실행 중이며 테스트 도중 HTTP POST 요청의 키/값 쌍과 실제 POST 데이터를 캡처하려고합니다. 다음 논리를 사용하여 POST 헤더의 키/값 쌍만 캡처 할 수 있지만 실제 POST 데이터는 아닙니다 (일명 양식 필드 ID 값). 실제로 POSTDATA를 캡처하는 방법이 있습니까 (예 : Firefox의 변조/라이브 헤더와 같은 스니핑 응용 프로그램과 같은 기능)?browsermob-proxy 및 selenium으로 http POST 요청을 캡처하는 방법
proxyServer.setCaptureContent(true);
proxyServer.setCaptureHeaders(true);
그런 다음 출력 실제 HAR 파일 :
을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());
}
}
});
내가 읽은하지만 동작하지 않습니다 수있는 또 다른 방법은 true로 browsermob 프록시 서버에서 다음 플래그를 구성 할 수 있었다
Har har = proxyServer.getHar();
Date date = new Date();
har.writeTo(new File("c:\\tmp\\har_" + date.getTime()));
키/값 쌍, POST 데이터 및 실제 응답 내용을 보려면 ... HAR 파일을 구문 분석 할 때 ... POST 헤더의 키/값 쌍만 다시 표시됩니다. POST 데이터가 없습니다 ... 응답 없음 콘텐츠. 비록 실제 POST 데이터에만 관심이 있습니다.
결국 내 작업 공간에 대한 browsermob 프록시 프로젝트를 체크 아웃 한 후에는 마음에 들지 않습니다. proxyServer.setCaptureContent (true) 및 proxyServer.setCaptureHeaders (true)는 HAR obj 내부의 POST 매개 변수를 캡처하기 위해 작동해야합니다. proxyServer.addRequestInterceptor는 POST 매개 변수를 캡처하지 않습니다. – Selwyn
이 댓글은 정말로 답변 일 것입니다. 그러나 코멘트에 감사드립니다! –