Slow Selenium tests when using proxy with BrowserMob

最后都变了- 提交于 2019-12-10 14:07:35

问题


I am setting up a ChromeDriver using BrowserMob(http://bmp.lightbody.net/) for intercepting HTTP responses.

ProxyServer proxyServer = null;
proxyServer = new ProxyServer(9101);
proxyServer.start();

proxyServer.setCaptureContent(true);
proxyServer.setCaptureHeaders(true);

Proxy proxy = proxyServer.seleniumProxy();
proxy.setHttpProxy("localhost:9101");


proxyServer.addResponseInterceptor(new ResponseInterceptor() {

@Override
public void process(BrowserMobHttpResponse response, Har har) {
    if (response.getRawResponse().getStatusLine().getStatusCode() == 500) {
                    // do something
                }

            }
        });

DesiredCapabilities capabilities = DesiredCapabilities.chrome();
capabilities.setCapability(CapabilityType.PROXY, proxy);

System.setProperty("webdriver.chrome.driver", "seleniumdrivers/chromedriver.exe");
ChromeOptions options = new ChromeOptions();
options.addArguments("--lang=nl");
capabilities.setCapability(ChromeOptions.CAPABILITY, options);
this.driver = new ChromeDriver(capabilities);

When running a Selenium test every page load is extremely slow. Without the proxy it works fine. Anyone knows the reason/ solution for this?

In the log console the following message appears: jan 10, 2014 12:58:06 PM net.sf.uadetector.datastore.AbstractUpdateOperation isUpdateAvailable INFO: Can not check for an updated version. Are you sure you have an established internet connection? No idea if this is related. Running Selenium tests on an online website (not local server), which means I have internet connection

来源:https://stackoverflow.com/questions/21043928/slow-selenium-tests-when-using-proxy-with-browsermob

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!