/** * Converts this proxy to a "selenium" proxy that can be used by webdriver */ public Proxy createSeleniumProxy() { return isEmpty(config.proxyHost()) ? ClientUtil.createSeleniumProxy(proxy) : ClientUtil.createSeleniumProxy(proxy, inetAddressResolver.getInetAddressByName(config.proxyHost())); }
/** * Creates a Selenium Proxy object from the BrowserMobProxy instance. The BrowserMobProxy must be started. Retrieves the address * of the Proxy using {@link #getConnectableAddress()}. * * @param browserMobProxy started BrowserMobProxy instance to read connection information from * @return a Selenium Proxy instance, configured to use the BrowserMobProxy instance as its proxy server * @throws java.lang.IllegalStateException if the proxy has not been started. */ public static org.openqa.selenium.Proxy createSeleniumProxy(BrowserMobProxy browserMobProxy) { return createSeleniumProxy(browserMobProxy, getConnectableAddress()); }
/** * @deprecated use {@link net.lightbody.bmp.client.ClientUtil#getConnectableAddress()} */ @Override @Deprecated public InetAddress getConnectableLocalHost() throws UnknownHostException { return ClientUtil.getConnectableAddress(); }
/** * @deprecated use {@link net.lightbody.bmp.client.ClientUtil#createSeleniumProxy(BrowserMobProxy)} */ @Override @Deprecated public Proxy seleniumProxy() throws NameResolutionException { return ClientUtil.createSeleniumProxy(this); }
/** * Creates a Selenium Proxy object from the BrowserMobProxy instance, using the specified connectableAddress as the Selenium Proxy object's * proxy address. Determines the port using {@link net.lightbody.bmp.BrowserMobProxy#getPort()}. The BrowserMobProxy must be started. * * @param browserMobProxy started BrowserMobProxy instance to read the port from * @param connectableAddress the network address the Selenium Proxy will use to reach this BrowserMobProxy instance * @return a Selenium Proxy instance, configured to use the BrowserMobProxy instance as its proxy server * @throws java.lang.IllegalStateException if the proxy has not been started. */ public static org.openqa.selenium.Proxy createSeleniumProxy(BrowserMobProxy browserMobProxy, InetAddress connectableAddress) { return createSeleniumProxy(new InetSocketAddress(connectableAddress, browserMobProxy.getPort())); }
@Override public Object getSeleniumProxy(int port) { logger.info ("Get Proxy for the port "+ port); BrowserMobProxy proxy = this.getProxy(port); return ClientUtil.createSeleniumProxy(proxy); } }
private DesiredCapabilities enableProxy(Capabilities capabilities) { DesiredCapabilities caps = new DesiredCapabilities(capabilities); try { InetAddress proxyInetAddress = InetAddress.getByName(proxyIp); BrowserMobProxy browserMobProxy = proxyController.startProxyServer(proxyInetAddress); Proxy seleniumProxy = ClientUtil.createSeleniumProxy(browserMobProxy, proxyInetAddress); caps.setCapability(CapabilityType.PROXY, seleniumProxy); } catch (UnknownHostException e) { throw new IllegalStateException(e); } return caps; } }
private DesiredCapabilities enableProxy(Capabilities capabilities) { DesiredCapabilities caps = new DesiredCapabilities(capabilities); try { InetAddress proxyInetAddress = InetAddress.getByName(proxyIp); BrowserMobProxy browserMobProxy = proxyController.startProxyServer(proxyInetAddress); Proxy seleniumProxy = ClientUtil.createSeleniumProxy(browserMobProxy, proxyInetAddress); caps.setCapability(CapabilityType.PROXY, seleniumProxy); } catch (UnknownHostException e) { throw new IllegalStateException(e); } return caps; } }
public Proxy startBrowserMobProxyServer() { start(); return ClientUtil.createSeleniumProxy(this); }
private static void configureProxy(DesiredCapabilities capabilities) { if (!WEBDRIVER_PROXY.isEmpty()) { setProxy(new BrowserMobProxyServer()); proxy.start(0); Proxy seleniumProxy = ClientUtil.createSeleniumProxy(proxy); capabilities.setCapability(CapabilityType.PROXY, seleniumProxy); } }
@Override public void afterPropertiesSet() throws Exception { if(enable) { server = new BrowserMobProxyServer(); server.start(); int port = server.getPort(); Proxy proxy = ClientUtil.createSeleniumProxy(server); proxy.setHttpProxy("127.0.0.1:" + port); proxy.setSslProxy("127.0.0.1:" + port); capabilities.setCapability(CapabilityType.PROXY, proxy); System.out.println("BrowserMobProxyServer@" + port); } }
private WebDriver getDriver(boolean useBrowserMobProxy) { if (null != webdriver && usingBrowserMobProxy != useBrowserMobProxy) { webdriver.quit(); webdriver = null; } if (null == webdriver) { Proxy proxy = null; if (proxyEnabled || useBrowserMobProxy) { if (useBrowserMobProxy) { usingBrowserMobProxy = true; browserMobProxy = new BrowserMobProxyServer(); browserMobProxy.start(); if (proxyEnabled) { browserMobProxy.setChainedProxy(new InetSocketAddress(proxyHostname, proxyPort)); } proxy = ClientUtil.createSeleniumProxy(browserMobProxy); } else { proxy = new Proxy(); proxy.setProxyType(MANUAL); proxy.setHttpProxy(proxyDetails); proxy.setSslProxy(proxyDetails); } } determineEffectiveDriverType(); DesiredCapabilities desiredCapabilities = selectedDriverType.browser.getDesiredCapabilities(proxy); instantiateWebDriver(desiredCapabilities); } return webdriver; }
mobProxy.enableHarCaptureTypes(CaptureType.REQUEST_CONTENT, CaptureType.REQUEST_HEADERS, CaptureType.RESPONSE_HEADERS); mobProxy.start(0); Proxy seleniumProxy = ClientUtil.createSeleniumProxy(mobProxy);