I am using selenium and java with my automation tests. I am forced to send authorization token in my tests so I used BrowserMobProxy library. Here is my setUp in @BeforeClass:
BrowserMobProxy proxy = new BrowserMobProxyServer();
proxy.setTrustAllServers(true);
proxy.addHeader("Authorization",tokenIDdev2);
proxy.start();
Next, this that I need to do is opening my browser by special proxy address, I've found this kind of setting up proxy address:
Proxy seleniumProxy = ClientUtil.createSeleniumProxy(proxy);
DesiredCapabilities capabilities = new DesiredCapabilities();
seleniumProxy.setHttpProxy(PROXY_ADDRESS);
seleniumProxy.setSslProxy(PROXY_ADDRESS);
capabilities.setCapability(CapabilityType.PROXY, seleniumProxy);
// Setting up Proxy for chrome
ChromeOptions opts = new ChromeOptions();
opts.merge(capabilities);
driver = new ChromeDriver(opts);
Problem is that when I am connecting by proxy which was set up in the method above, requests are not sending with the header that I specified in the first part.
Do you have any ideas that I am doing wrong, or maybe there is another way to handle this situation?
Thanks!