3

我已经在嵌入式模式下使用BrowserMob代理实现了 Selenium。

我还向代理添加了一个请求和响应过滤器,它成功过滤了所有请求和响应。但是我如何跟踪特定请求,例如在该请求收到响应时实现回调函数。我还需要根据无法设置为静态变量的响应修改一些对象,因为会同时运行多个测试。有什么办法可以做到这一点。?任何帮助或信息将不胜感激。

当前过滤器实现:(刚刚添加了文档中的代码)

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  
             * 
             */
        }
    });
4

0 回答 0