Search in sources :

Example 1 with BrowserName

use of ru.sbtqa.tag.pagefactory.web.support.BrowserName 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)

Aggregations

Proxy (org.openqa.selenium.Proxy)1 UnsupportedBrowserException (ru.sbtqa.tag.pagefactory.exceptions.UnsupportedBrowserException)1 WebDriverCapabilitiesParser (ru.sbtqa.tag.pagefactory.web.capabilities.WebDriverCapabilitiesParser)1 BrowserName (ru.sbtqa.tag.pagefactory.web.support.BrowserName)1