I have implemented Selenium with BrowserMob proxy in embedded mode.
I have also added a request and response filter to the proxy which successfully filters all the requests and responses. But how do I track a specific request, like implementing a callback function when that request receives a response. I also need to modify few objects based on the response which cannot be set as a static variable since there would be multiple tests running simultaneously. Is there any way to achieve this.? Any help or info would be really appreciated.
Current Filter Implementation : (just added the code as in the docs)
proxy.addRequestFilter(new RequestFilter() {
@Override
public HttpResponse filterRequest(HttpRequest request, HttpMessageContents contents, HttpMessageInfo messageInfo) {
if (request.getMethod() == HttpMethod.POST) {
/*
* Track this request and resume operations
* once the response is recieved
*/
}
return null;
}
});
proxy.addResponseFilter(new ResponseFilter() {
@Override
public void filterResponse(HttpResponse response, HttpMessageContents contents, HttpMessageInfo messageInfo) {
if (/*required request receives response) {
/*
* should be able to pass(somehow need to access)
* an variable to set the status
*
*/
}
});