browsermob-proxy: Embedded mode with selenium doesn't load website
When using embedded mode in a selenium test, websites will timeout and not load. I have tried on google, npr.org, yahoo.com, etc. I’ve tried a couple things to see if it makes a difference but no luck so far: setting setUseECC to true, setTrustAllServers to true. I’ve tried on 2 different machines and same results. Is there something I’m missing?
Java v8 selenium v3.3.1 bmp v2.1.4
Here is my test case:
// Create bmp proxy
BrowserMobProxyServer proxy = new BrowserMobProxyServer();
// proxy.start(0);
try {
proxy.start(9091, InetAddress.getLocalHost());
} catch (UnknownHostException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
proxy.setHarCaptureTypes(CaptureType.getAllContentCaptureTypes());
proxy.enableHarCaptureTypes(CaptureType.REQUEST_CONTENT, CaptureType.RESPONSE_CONTENT);
proxy.setUseEcc(true);
// Pass the proxy into desired capabilities
Proxy seleniumProxy = ClientUtil.createSeleniumProxy(proxy);
DesiredCapabilities caps = new DesiredCapabilities();
caps = DesiredCapabilities.chrome();
caps.setCapability(CapabilityType.PROXY, seleniumProxy);
// Turning off pop-up blocking
ChromeOptions options = new ChromeOptions();
options.addArguments("test-type");
options.addArguments("disable-popup-blocking");
caps.setCapability(ChromeOptions.CAPABILITY, options);
// Create the browser session
File file = new File(this.getClass().getResource(Constants.DRIVERS_PATH_LOCAL + "ChromeDriver.exe").getPath());
System.setProperty("webdriver.chrome.driver", file.getAbsolutePath());
WebDriver driver = new ChromeDriver(caps);
// Create the har file
proxy.newHar("SalesforceAddCandidate");
// load website stuff
driver.get("http://www.npr.org/");
Har har = proxy.getHar();
File harFile = new File("C:\\temp\\SalesforceAddCandidate");
try {
har.writeTo(harFile);
} catch (IOException ex) {
System.out.println(ex.toString());
}
proxy.stop();
About this issue
- Original URL
- State: open
- Created 7 years ago
- Comments: 29
try this. hope that works
replace this
with
great news!! you definitely are not cursed 😃