List of usage examples for org.openqa.selenium.ie InternetExplorerDriverService createDefaultService
public static InternetExplorerDriverService createDefaultService()
From source file:com.vilt.minium.script.impl.InternetExplorerDriverFactory.java
License:Apache License
protected void maybeInitInternetExplorerDriverService() { try {/*ww w . j av a 2 s . c o m*/ if (service == null) { File baseWebDriver = new File(new File(preferences.getBaseDir(), "drivers"), "IEDriverServer.exe"); if (baseWebDriver.isFile() && baseWebDriver.canExecute()) { service = new InternetExplorerDriverService.Builder().usingDriverExecutable(baseWebDriver) .usingAnyFreePort().build(); } else { service = InternetExplorerDriverService.createDefaultService(); } service.start(); logger.debug("IE driver service initialized: {}", service.getUrl()); } } catch (IOException e) { throw Throwables.propagate(e); } }
From source file:org.emonocot.portal.driver.WebDriverFacade.java
License:Open Source License
/** * * @return the webdriver//from w ww.j a va2 s .c o m * @throws IOException if there is a problem loading the * properties file */ private WebDriver createWebDriver() throws IOException { Resource propertiesFile = new ClassPathResource("META-INF/spring/application.properties"); Properties properties = new Properties(); properties.load(propertiesFile.getInputStream()); String webdriverMode = properties.getProperty("selenium.webdriver.mode", "local"); String driverName = properties.getProperty("selenium.webdriver.impl", "org.openqa.selenium.firefox.FirefoxDriver"); WebDriverBrowserType browser = WebDriverBrowserType.fromString(driverName); String display = properties.getProperty("selenium.display.port", ":0"); if (webdriverMode.equals("local")) { switch (browser) { case CHROME: String chromeLocation = properties.getProperty("selenium.webdriver.chromedriver.location"); Map<String, String> environment = new HashMap<String, String>(); environment.put("DISPLAY", display); ChromeDriverService chromeService = new ChromeDriverService.Builder() .usingDriverExecutable(new File(chromeLocation)).usingAnyFreePort() .withEnvironment(environment).build(); chromeService.start(); return new RemoteWebDriver(chromeService.getUrl(), DesiredCapabilities.chrome()); case SAFARI: return new SafariDriver(); case INTERNET_EXPLORER: String internetExplorerLocation = properties.getProperty("selenium.webdriver.ie.location"); InternetExplorerDriverService ieService = InternetExplorerDriverService.createDefaultService(); ieService.start(); return new RemoteWebDriver(ieService.getUrl(), DesiredCapabilities.internetExplorer()); case FIREFOX: default: FirefoxBinary firefoxBinary = new FirefoxBinary(); firefoxBinary.setEnvironmentProperty("DISPLAY", display); ProfilesIni allProfiles = new ProfilesIni(); FirefoxProfile profile = allProfiles.getProfile("default"); return new FirefoxDriver(firefoxBinary, profile); } } else { DesiredCapabilities capabilities = new DesiredCapabilities(); switch (browser) { case CHROME: capabilities = DesiredCapabilities.chrome(); break; case INTERNET_EXPLORER: capabilities = DesiredCapabilities.internetExplorer(); break; case SAFARI: capabilities = DesiredCapabilities.safari(); break; case FIREFOX: default: capabilities = DesiredCapabilities.firefox(); } String platformName = properties.getProperty("selenium.webdriver.platformName", "LINUX"); WebDriverPlatformType platform = WebDriverPlatformType.valueOf(platformName); switch (platform) { case MAC: capabilities.setPlatform(Platform.MAC); break; case WINDOWS: capabilities.setPlatform(Platform.WINDOWS); break; case LINUX: default: capabilities.setPlatform(Platform.LINUX); } return new RemoteWebDriver(new URL("http://build.e-monocot.org:4444/wd/hub"), capabilities); } }