BrowserMobProxy Not working inside selenium Grid on docker
See original GitHub issueI can able to run and get Response Header Using browsermob and selenium using following code
DesiredCapabilities capabilities = new DesiredCapabilities();
BrowserMobProxy proxy = getProxyServer(); //getting browsermob proxy
Proxy seleniumProxy = getSeleniumProxy(proxy);
capabilities.setCapability(CapabilityType.PROXY, seleniumProxy);
capabilities.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
WebDriver driver = new ChromeDriver(capabilities);
proxy.setHarCaptureTypes(CaptureType.REQUEST_HEADERS,CaptureType.RESPONSE_HEADERS);
proxy.newHar(); // creating new HAR
driver.get("https://www.google.com");
List<HarEntry> entries = proxy.getHar().getLog().getEntries();
for (HarEntry entry : entries) {
System.out.println(entry.getRequest().getUrl());
}
proxy.stop();
driver.close();
}
public Proxy getSeleniumProxy(BrowserMobProxy proxyServer) {
Proxy seleniumProxy = ClientUtil.createSeleniumProxy(proxyServer);
try {
String hostIp = Inet4Address.getLocalHost().getHostAddress();
seleniumProxy.setHttpProxy(hostIp + ":" + proxyServer.getPort());
seleniumProxy.setSslProxy(hostIp + ":" + proxyServer.getPort());
} catch (UnknownHostException e) {
e.printStackTrace();
Assert.fail("invalid Host Address");
}
return seleniumProxy;
}
public BrowserMobProxy getProxyServer() {
BrowserMobProxy proxy = new BrowserMobProxyServer();
proxy.setTrustAllServers(true);
proxy.start();
return proxy;
}
But I am getting problem when i am running it to the selenium docker container
By using this code i can able to open chromebrowser
DesiredCapabilities capabilities =new DesiredCapabilities();
capabilities.setBrowserName("chrome");
capabilities.setPlatform(Platform.getCurrent());
BrowserMobProxy proxy = getProxyServer(); //getting browsermob proxy
Proxy seleniumProxy = getSeleniumProxy(proxy);
capabilities.setCapability(CapabilityType.PROXY, seleniumProxy);
driver = new RemoteWebDriver(new URL("http://172.17.0.3:5555/wd/hub"), capabilities);
proxy.setHarCaptureTypes(CaptureType.REQUEST_HEADERS, CaptureType.RESPONSE_HEADERS);
proxy.newHar();
driver.get("https://www.google.com");
But its shows
No internet There is something wrong with the proxy server, or the address is incorrect.
Can anyone know how to run this inside selenium docker container.Thanks advance for your help.
Issue Analytics
- State:
- Created 5 years ago
- Comments:5
Top Results From Across the Web
Running browsermob with selenium grid on docker
To Answer my own question based on the response from Sergey: I pushed a browsermob-proxy image to docker hub: ...
Read more >Browsermob proxy how to make it work with selenium grid ...
PROXY, seleniumProxy);. The problem is running on local its fine but running it on grid(either own or browserstack) it is not working.
Read more >How to Setup Selenium Grid with BrowserMob-Proxy to pass ...
Create docker-compose to run Selenium Grid ... Selenium provide proxy implementation but that does not provide request manipulation.
Read more >How To Use On The Remote Server From Docker - ADocLib
If you're running BrowserMob Proxy within a Java application or Selenium ... The problem is running on local its fine but running it...
Read more >Gridlastic Connect
Note: if you are using Docker Desktop see our Docker containers ... Starting a tunnel does not affect your selenium grid nodes capability...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Browsermobproxy is from a time before docker containers. If you run your browser in the container, and the proxy outside it, you will need to make a small change to your code, using either
host.docker.internal
orgateway.docker.internal
I tried with host.docker.internal in my python code …But it’s not working. Can you please explain how to implement the browsermobproxy in python with selenium grid. The code to start browsermobproxy server and client is running on my chrome node. is this the correct way?