kelseyde
kelseyde

Reputation: 1

BrowserMob Proxy not injecting headers with new Chrome version

I recently upgraded my Chrome/Chromedriver from v69 to the latest v76, and my suite of Selenium tests - which use BrowserMob Proxy to inject HTTP headers - have stopped working. The ChromeDriver will open the browser OK, but the headers are no longer being injected.

Chrome, Selenium and BrowserMob Proxy are now all on the latest versions:

  1. Chrome: 76.0.3809.132
  2. BrowserMob: 2.1.5
  3. Selenium: 3.141.59

Does anyone know whether there are compatibility issues with the latest Chrome and BrowserMob? Or, can anyone spot an issue in my code?

Any help is much appreciated!

Here is my code:

Proxy seleniumProxy = null;
    try {

        String hostIp = Inet4Address.getLocalHost().getHostAddress();

        proxy.setTrustAllServers(true);
        proxy.start(0, Inet4Address.getByName(hostIp));

        proxy.addRequestFilter((request, contents, messageInfo) -> {
            headerMap.forEach((key, value) -> {
                if (key != null && value != null) {
                    request.headers().add((String) key, value);
                }
            });
            return null;  //continue regular processing...
        });

        seleniumProxy = ClientUtil.createSeleniumProxy(proxy, InetAddress.getByName(hostIp));
        seleniumProxy.setHttpProxy(hostIp + ":" + proxy.getPort());
        seleniumProxy.setSslProxy(hostIp + ":" + proxy.getPort());
        System.out.println("Created proxy on port " + proxy.getPort());

    } catch (UnknownHostException e) {
        LOG.error("unable to create BrowerMob proxy", e);
    }
    return seleniumProxy;

Upvotes: 0

Views: 392

Answers (0)

Related Questions