use of ru.sbtqa.tag.pagefactory.exceptions.UnsupportedBrowserException 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());
}
Aggregations