I am able to modify http request header using BrowserMobProxy, the same way explained


But, the problem I am having at the moment is, that I am executing my scenarios on dev/local/playpen environment (environment before System integration testing). And to open the website on this environment needs proxy to set.

When I set my proxy then it fails to modify header and apply the proxy. When I comment the proxy part then it easily modifies the header.

BrowserMobProxy proxy = new BrowserMobProxyServer();
Proxy seleniumProxy = ClientUtil.createSeleniumProxy(proxy);

proxy.addRequestFilter((request, contents, messageInfo)->{
    request.headers().add("some-header-attribute", "RandomeValue");
    return null;

String _host = Utils.getConfigValue("proxy.host");
String _port = Utils.getConfigValue("proxy.port");

seleniumProxy.setHttpProxy(_host + ":" + _port);
seleniumProxy.setSslProxy(_host + ":" + _port);
seleniumProxy.setFtpProxy(_host + ":" + _port);
capabilities.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);

String proxyOption = "--proxy-server=" + seleniumProxy.getHttpProxy();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.