Reputation: 125
What I have in my code:
public BrowserMobProxy getProxy() throws UnknownHostException {
if (proxy == null) {
proxy = new BrowserMobProxyServer();
proxy.start(0);
}
return proxy;
seleniumProxy = ClientUtil.createSeleniumProxy(getProxy());
caps.setCapability(CapabilityType.PROXY, seleniumProxy);
The problem is running on local its fine but running it on grid(either own or browserstack) it is not working. Is there any way how to make it work - proxy running on local and listening to remote driver?
I tried:
proxy.start(0, InetAddress.getLocalHost());
But without success.
Upvotes: 1
Views: 3392
Reputation: 1
I got stuck with the same issue. I use the following stack:
I get it working by the following code (I make bold the key code):
proxy = new BrowserMobProxyServer();
proxy.start(0);
Proxy seleniumProxy = null;
seleniumProxy = ClientUtil.createSeleniumProxy(proxy);
String ipAddress = new NetworkUtils().getIp4NonLoopbackAddressOfThisMachine().getHostAddress();
int port = proxy.getPort();
seleniumProxy.setHttpProxy(ipAddress + ":" + port);
DesiredCapabilities capability = DesiredCapabilities.chrome();
capability.setCapability(CapabilityType.PROXY, seleniumProxy);
driver = new RemoteWebDriver(new URL("your_selnium_hub_ip:4444/wd/hub"), capability);
Upvotes: 0
Reputation: 665
I've managed to solve this problem by using standalone browsermob instance and connecting to it via REST api. You can manage remote instance using simple GET/POST/PUT requests as described in REST API section: https://github.com/lightbody/browsermob-proxy
OR you could try and expose your local proxy(but it will be necessary to assigned real address to it) externally and see what is going to happen.
Upvotes: 1