Slow Selenium tests when using proxy with BrowserMob
Asked Answered
C

0

8

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

Certie answered 10/1, 2014 at 12:4 Comment(4)
Could be related to issue BrowserMob Proxy extremely slow when recording HAR file. Can you confirm if it's getting stuck on accessing UserAgentInfo?Vertu
thanks, while digging into it I noticed it is a network issue. The browser is stuck on calling code.jquery.com (which is declared as script in html) and returns a timeout when using browsermob. I am connected to an office network with specific proxy settings. The webapplication I am testing is hosted somewhere inside the office network. Apparently I can't access any online website with the browsermob proxyCertie
@Charlie, Did you find the solution is for it? I am also stuck with the same problem..I am not able to access any website with browsermob proxyEufemiaeugen
@Eufemiaeugen no actually I didn't find a solution for thisCertie

© 2022 - 2024 — McMap. All rights reserved.