Open ChrisD1990 opened 4 years ago
while open page , always show cannot connect network, can you help me see see?
![Uploading image.png…]()
private static DesiredCapabilities startBrowserMobProxy() {
DesiredCapabilities capabilities = new DesiredCapabilities();
BrowserMobProxy browserMobProxy = new BrowserMobProxyServer();
browserMobProxy.setTrustAllServers(true);
browserMobProxy.start(9092);
browserMobProxy.enableHarCaptureTypes(CaptureType.getAllContentCaptureTypes());
String hostIp = new NetworkUtils().getIp4NonLoopbackAddressOfThisMachine().getHostAddress();
Proxy proxy = ClientUtil.createSeleniumProxy(new InetSocketAddress(hostIp, browserMobProxy.getPort()));
proxy.setHttpProxy(hostIp + ":" + browserMobProxy.getPort());
proxy.setSslProxy(hostIp + ":" + browserMobProxy.getPort());
capabilities.setCapability(CapabilityType.PROXY, proxy);
capabilities.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
capabilities.setCapability(CapabilityType.ACCEPT_INSECURE_CERTS, true);
browserMobProxyThreadLocal.set(browserMobProxy);
System.out.println("jvm-assign port for bmp:" + browserMobProxy.getPort());
return capabilities;
}
hi,
i meet a issue, as our automation is seleniume grid, i have 1 hub node and 9 salve node, now i want to use the browsermorb-proxy, I don’t know which salve node it will run automation case, so can you help tell me should i to do? thanks
Below is my code: public void startproxy(String url) { BrowserMobProxy proxy = new BrowserMobProxyServer(); proxy.start(0); // get the Selenium proxy object RemoteWebDriver rDriver = (RemoteWebDriver) ((WebDriverFacade) getDriver()).getProxiedDriver(); String browser = rDriver.getCapabilities().getBrowserName().toLowerCase(); // String browser = ConfigParser.getBrowser(); Proxy seleniumProxy = ClientUtil.createSeleniumProxy(proxy);
// driver = new ChromeDriver(chromeCapabilities); } else { System.out.println("Using default browser as firefox"); DesiredCapabilities capabilities = DesiredCapabilities.firefox(); capabilities.setCapability("marionette", true); driver = new FirefoxDriver(capabilities); } try { proxy.newHar("swtestacademy"); driver.get(url); try { Thread.sleep(10000); } catch (InterruptedException e) { e.printStackTrace(); } Har har = proxy.getHar(); File harFile = new File("academy.har"); har.writeTo(harFile); } catch (IOException ioe) { ioe.printStackTrace(); } // driver.quit(); // proxy.stop(); }