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());
}
Aggregations