Search in sources :

Example 1 with Proxy

use of org.openqa.selenium.Proxy in project page-factory-2 by sbtqa.

the class TagWebDriver method createDriver.

private static void createDriver() throws UnsupportedBrowserException, MalformedURLException {
    DesiredCapabilities capabilities = new WebDriverCapabilitiesParser().parse();
    if (!PROPERTIES.getProxy().isEmpty()) {
        Proxy seleniumProxy = ProxyConfigurator.configureProxy();
        capabilities.setCapability(CapabilityType.PROXY, seleniumProxy);
    }
    String browserName = getBrowserName();
    capabilities.setBrowserName(browserName);
    String webDriverUrl = PROPERTIES.getWebDriverUrl();
    if (!webDriverUrl.isEmpty()) {
        setWebDriver(createRemoteWebDriver(webDriverUrl, capabilities));
    } else {
        if (browserName.equalsIgnoreCase(FIREFOX)) {
            setWebDriver(new FirefoxDriver(capabilities));
        } else if (browserName.equalsIgnoreCase(SAFARI)) {
            setWebDriver(new SafariDriver(capabilities));
        } else if (browserName.equalsIgnoreCase(CHROME)) {
            WebDriverManagerConfigurator.configureDriver(ChromeDriverManager.getInstance(), CHROME);
            setWebDriver(new ChromeDriver(capabilities));
        } else if (browserName.equalsIgnoreCase(IE)) {
            WebDriverManagerConfigurator.configureDriver(InternetExplorerDriverManager.getInstance(), IE);
            setWebDriver(new InternetExplorerDriver(capabilities));
        } else {
            throw new UnsupportedBrowserException("'" + browserName + "' is not supported yet");
        }
    }
    webDriver.manage().timeouts().pageLoadTimeout(PageFactory.getTimeOutInSeconds(), TimeUnit.SECONDS);
    setBrowserSize();
    webDriver.get(PROPERTIES.getStartingUrl());
}
Also used : UnsupportedBrowserException(ru.sbtqa.tag.pagefactory.exceptions.UnsupportedBrowserException) Proxy(org.openqa.selenium.Proxy) FirefoxDriver(org.openqa.selenium.firefox.FirefoxDriver) InternetExplorerDriver(org.openqa.selenium.ie.InternetExplorerDriver) DesiredCapabilities(org.openqa.selenium.remote.DesiredCapabilities) WebDriverCapabilitiesParser(ru.sbtqa.tag.pagefactory.support.capabilities.WebDriverCapabilitiesParser) ChromeDriver(org.openqa.selenium.chrome.ChromeDriver) SafariDriver(org.openqa.selenium.safari.SafariDriver)

Example 2 with Proxy

use of org.openqa.selenium.Proxy in project page-factory-2 by sbtqa.

the class ProxyConfigurator method configureProxy.

public static Proxy configureProxy() {
    BrowserMobProxy browserMobProxy = new BrowserMobProxyServer();
    browserMobProxy.start(0);
    Proxy seleniumProxy = ClientUtil.createSeleniumProxy(browserMobProxy);
    return seleniumProxy;
}
Also used : Proxy(org.openqa.selenium.Proxy) BrowserMobProxy(net.lightbody.bmp.BrowserMobProxy) BrowserMobProxy(net.lightbody.bmp.BrowserMobProxy) BrowserMobProxyServer(net.lightbody.bmp.BrowserMobProxyServer)

Example 3 with Proxy

use of org.openqa.selenium.Proxy in project page-factory-2 by sbtqa.

the class WebDriverService method createDriver.

private void createDriver() throws UnsupportedBrowserException, MalformedURLException {
    DesiredCapabilities capabilities = new WebDriverCapabilitiesParser().parse();
    if (!PROPERTIES.getProxy().isEmpty()) {
        Proxy seleniumProxy = ProxyConfigurator.configureProxy();
        capabilities.setCapability(CapabilityType.PROXY, seleniumProxy);
    }
    BrowserName browserName = WebEnvironment.getBrowserName();
    capabilities.setBrowserName(browserName.getName());
    String webDriverUrl = PROPERTIES.getWebDriverUrl();
    if (!webDriverUrl.isEmpty()) {
        setWebDriver(createRemoteWebDriver(webDriverUrl, capabilities));
    } else {
        if (browserName.equals(BrowserName.FIREFOX)) {
            setWebDriver(new CreatedFirefoxDriver(capabilities).get());
        } else if (browserName.equals(BrowserName.SAFARI)) {
            setWebDriver(new CreatedSafariDriver(capabilities).get());
        } else if (browserName.equals(BrowserName.CHROME)) {
            setWebDriver(new CreatedChromeDriver(capabilities).get());
        } else if (browserName.equals(BrowserName.INTERNET_EXPLORER)) {
            setWebDriver(new CreatedInternetExplorerDriver(capabilities).get());
        } else if (browserName.equals(BrowserName.EDGE)) {
            setWebDriver(new CreatedEdgeDriver(capabilities).get());
        } else {
            throw new UnsupportedBrowserException("'" + browserName + "' is not supported yet");
        }
    }
    webDriver.manage().timeouts().pageLoadTimeout(PROPERTIES.getTimeout(), TimeUnit.SECONDS);
    setBrowserSize();
    webDriver.get(PROPERTIES.getStartingUrl());
}
Also used : BrowserName(ru.sbtqa.tag.pagefactory.web.support.BrowserName) UnsupportedBrowserException(ru.sbtqa.tag.pagefactory.exceptions.UnsupportedBrowserException) Proxy(org.openqa.selenium.Proxy) WebDriverCapabilitiesParser(ru.sbtqa.tag.pagefactory.web.capabilities.WebDriverCapabilitiesParser)

Example 4 with Proxy

use of org.openqa.selenium.Proxy in project NoraUi by NoraUi.

the class Context method initializeRobot.

public synchronized void initializeRobot(Class<?> clazz) throws TechnicalException {
    logger.info("Context > initializeRobot() with " + clazz.getCanonicalName());
    // set browser: chrome,firefox or ie
    browser = getProperty(BROWSER_KEY, applicationProperties);
    // set Webdriver file: src/test/resources/drivers/...
    initializeWebdriversProperties(Thread.currentThread().getContextClassLoader());
    // wait delay until web element is displayed.
    timeout = setIntProperty(TIMEOUT_KEY, applicationProperties);
    // set version of selectors used to deliver several versions
    selectorsVersion = getProperty(SELECTORS_VERSION, applicationProperties);
    // proxies configuration
    proxy = new Proxy();
    proxy.setAutodetect(true);
    final String httpProxy = getProperty(HTTP_PROXY, applicationProperties);
    if (httpProxy != null && !"".equals(httpProxy)) {
        proxy.setAutodetect(false);
        proxy.setHttpProxy(httpProxy);
    }
    final String httpsProxy = getProperty(HTTPS_PROXY, applicationProperties);
    if (httpsProxy != null && !"".equals(httpsProxy)) {
        proxy.setAutodetect(false);
        proxy.setSslProxy(httpsProxy);
    }
    final String noProxy = getProperty(NO_PROXY, applicationProperties);
    if (noProxy != null && !"".equals(noProxy)) {
        proxy.setAutodetect(false);
        proxy.setNoProxy(noProxy);
    }
    // authentication mode configuration
    Auth.setAuthenticationType(getProperty(AUTH_TYPE, applicationProperties));
    // stacktrace configuration
    displayStackTrace = "true".equals(getProperty(DISPLAY_STACK_TRACE, applicationProperties));
    // enable browser headless mode ?
    isHeadless = "true".equals(getProperty(HEADLESS, applicationProperties));
    // init driver callbacks
    exceptionCallbacks.put(Callbacks.RESTART_WEB_DRIVER, STEPS_BROWSER_STEPS_CLASS_QUALIFIED_NAME, RESTART_WEB_DRIVER_METHOD_NAME);
    exceptionCallbacks.put(Callbacks.CLOSE_WINDOW_AND_SWITCH_TO_DEMO_HOME, STEPS_BROWSER_STEPS_CLASS_QUALIFIED_NAME, GO_TO_URL_METHOD_NAME, DEMO_HOME);
    exceptionCallbacks.put(Callbacks.CLOSE_WINDOW_AND_SWITCH_TO_LOGOGAME_HOME, STEPS_BROWSER_STEPS_CLASS_QUALIFIED_NAME, GO_TO_URL_METHOD_NAME, LOGOGAME_HOME);
    exceptionCallbacks.put(Callbacks.CLOSE_WINDOW_AND_SWITCH_TO_COUNTRIES_HOME, STEPS_BROWSER_STEPS_CLASS_QUALIFIED_NAME, GO_TO_URL_METHOD_NAME, COUNTRIES_HOME);
    // init applications
    initApplicationDom(clazz.getClassLoader(), selectorsVersion, DEMO_KEY);
    applications.put(DEMO_KEY, new Application(DEMO_HOME, getProperty(DEMO_KEY, applicationProperties) + "/index.html"));
    initApplicationDom(clazz.getClassLoader(), selectorsVersion, LOGOGAME_KEY);
    applications.put(LOGOGAME_KEY, new Application(LOGOGAME_HOME, getProperty(LOGOGAME_KEY, applicationProperties) + "/index.html"));
    initApplicationDom(clazz.getClassLoader(), selectorsVersion, COUNTRIES_KEY);
    applications.put(COUNTRIES_KEY, new Application(COUNTRIES_HOME, getProperty(COUNTRIES_KEY, applicationProperties) + "/index.html"));
    // read and init all cucumber methods
    cucumberMethods = Step.getAllCucumberMethods(clazz);
}
Also used : Proxy(org.openqa.selenium.Proxy) Application(com.github.noraui.application.Application)

Example 5 with Proxy

use of org.openqa.selenium.Proxy in project selenified by Coveros.

the class TestSetupTest method setupProxyTest.

@Test
public void setupProxyTest() {
    TestSetup setup = new TestSetup();
    setup.setupProxy();
    DesiredCapabilities capability = setup.getDesiredCapabilities();
    Assert.assertFalse(capability.is(CapabilityType.PROXY));
    System.setProperty("proxy", "localhost");
    setup.setupProxy();
    capability = setup.getDesiredCapabilities();
    Proxy export = (Proxy) capability.getCapability(CapabilityType.PROXY);
    Assert.assertEquals(export.getHttpProxy(), "localhost");
}
Also used : TestSetup(com.coveros.selenified.utilities.TestSetup) Proxy(org.openqa.selenium.Proxy) DesiredCapabilities(org.openqa.selenium.remote.DesiredCapabilities) Test(org.testng.annotations.Test)

Aggregations

Proxy (org.openqa.selenium.Proxy)28 Test (org.junit.Test)11 DesiredCapabilities (org.openqa.selenium.remote.DesiredCapabilities)6 BrowserMobProxy (net.lightbody.bmp.BrowserMobProxy)4 File (java.io.File)3 BrowserMobProxyServer (net.lightbody.bmp.BrowserMobProxyServer)3 ProxyHostPort (com.googlecode.jmeter.plugins.webdriver.proxy.ProxyHostPort)2 SystemProxy (com.qaprosoft.carina.proxy.SystemProxy)2 UnsupportedBrowserException (ru.sbtqa.tag.pagefactory.exceptions.UnsupportedBrowserException)2 TestSetup (com.coveros.selenified.utilities.TestSetup)1 BrowserVersion (com.gargoylesoftware.htmlunit.BrowserVersion)1 WebClient (com.gargoylesoftware.htmlunit.WebClient)1 Application (com.github.noraui.application.Application)1 FileServer (com.github.timurstrekalov.saga.core.FileServer)1 InstanceFieldPerPropertyConfig (com.github.timurstrekalov.saga.core.cfg.InstanceFieldPerPropertyConfig)1 InstrumentingProxyServer (com.github.timurstrekalov.saga.core.server.InstrumentingProxyServer)1 BrowserMobProxySupplier (com.hribol.automation.core.suppliers.BrowserMobProxySupplier)1 DesiredCapabilitiesSupplier (com.hribol.automation.core.suppliers.DesiredCapabilitiesSupplier)1 SeleniumProxySupplier (com.hribol.automation.core.suppliers.SeleniumProxySupplier)1 NetworkTrafficInterceptor (com.wikia.webdriver.common.core.networktrafficinterceptor.NetworkTrafficInterceptor)1