Slow Selenium tests when using proxy with BrowserMob

5.7k views Asked by At

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

0

There are 0 answers