Search in sources :

Example 1 with BrowserMobProxy

use of net.lightbody.bmp.BrowserMobProxy in project java.webdriver by sayems.

the class BrowserThreads method getDriver.

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;
}
Also used : Proxy(org.openqa.selenium.Proxy) BrowserMobProxy(net.lightbody.bmp.BrowserMobProxy) InetSocketAddress(java.net.InetSocketAddress) DesiredCapabilities(org.openqa.selenium.remote.DesiredCapabilities) BrowserMobProxyServer(net.lightbody.bmp.BrowserMobProxyServer)

Aggregations

InetSocketAddress (java.net.InetSocketAddress)1 BrowserMobProxy (net.lightbody.bmp.BrowserMobProxy)1 BrowserMobProxyServer (net.lightbody.bmp.BrowserMobProxyServer)1 Proxy (org.openqa.selenium.Proxy)1 DesiredCapabilities (org.openqa.selenium.remote.DesiredCapabilities)1