@Test public void settingBrowserSize() { // given WebDriverProperties properties = new WebDriverProperties(); properties.setProperty("browserSize", "1690x1000"); // when Capabilities convertedCapabilities = internetExplorerCapabilitiesConverter.convert(properties); // then // expected safari options InternetExplorerOptions expectedInternetExplorerOptions = new InternetExplorerOptions(); expectedInternetExplorerOptions.setCapability(CAPABILITY_AUTOCLOSE, false); expectedInternetExplorerOptions.setCapability(CAPABILITY_BROWSER_SIZE, "1690x1000"); assertThat(convertedCapabilities.asMap()).isEqualTo(expectedInternetExplorerOptions.asMap()); }
private void setOptions(InternetExplorerOptions options) { for (Map.Entry<Object, Object> entry : entrySet()) { String key = (String) entry.getKey(); if (key.startsWith("desired.capabilities.")) { String preferenceKey = key.substring(21); String value = (String) entry.getValue(); if (value.equalsIgnoreCase("true") || value.equalsIgnoreCase("false")) { boolean aBoolean = Boolean.valueOf(value); options.setCapability(preferenceKey, aBoolean); } else { try { int intValue = Integer.parseInt(value); options.setCapability(preferenceKey, intValue); } catch (NumberFormatException e) { options.setCapability(preferenceKey, value); } } } } LOGGER.info("The properties was load with success: {}", toString()); }
@Override public Capabilities convert(WebDriverProperties properties) { InternetExplorerOptions internetExplorerOptions = new InternetExplorerOptions(); // general options for logging purpose internetExplorerOptions.setCapability(CAPABILITY_AUTOCLOSE, properties.isAutoClose()); addToInternetExplorerOptionsIfNoEmptyValue(internetExplorerOptions, CAPABILITY_DRIVER_VERSION, properties.getDriverVersion()); addToInternetExplorerOptionsIfNoEmptyValue(internetExplorerOptions, CAPABILITY_BROWSER_SIZE, properties.getBrowserSize()); return internetExplorerOptions; }
public InternetExplorerOptions defaultIEOptions() { InternetExplorerOptions cap = new InternetExplorerOptions(); cap.setCapability(INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true); cap.setCapability("ignoreZoomSetting", true); //cap.setCapability("requireWindowFocus", true); return (InternetExplorerOptions) modifyCapabilities.apply(cap); }
@Override public InternetExplorerOptions getCapabilities() { InternetExplorerOptions ieOptions = new InternetExplorerOptions(); ieOptions.setCapability(CapabilityType.ForSeleniumServer.ENSURING_CLEAN_SESSION, true); ieOptions.setCapability(InternetExplorerDriver.ENABLE_PERSISTENT_HOVERING, true); ieOptions.setCapability("requireWindowFocus", true); return ieOptions; }
@Override public WebDriver create(WebDriverFactory webDriverFactory, DesiredCapabilities desiredCapabilities) { InternetExplorerDriverServiceProperties serviceProperties = webDriverFactory.driverServices == null ? null : webDriverFactory.driverServices.getInternetExplorer(); DriverService driverService = serviceProperties == null ? null : serviceProperties.getDriverService(); InternetExplorerOptions internetExplorerOptions = new InternetExplorerOptions().merge(desiredCapabilities); return driverService == null ? new InternetExplorerDriver(internetExplorerOptions) : new RemoteWebDriver(driverService.getUrl(), internetExplorerOptions); }
/*** * If you're using Selenium Grid, make sure the selenium server is in the same folder with the IEDriverServer * or include the path to the ChromeDriver in command line when registering the node: * -Dwebdriver.chrome.driver=%{path to chrome driver} * @return Internet Explorer capabilities */ private InternetExplorerOptions getOptions() { InternetExplorerOptions options = new InternetExplorerOptions(); setOptions(options); String driverPath = getProperty("browser.driver.path"); if (!"".equals(driverPath)) { System.setProperty("webdriver.ie.driver", driverPath); } return options; }
@Override public WebDriver createDriver(URL remoteUrl) throws IOException { InternetExplorerOptions capabilities = getOptions(); if (isRemoteDriver()) { RemoteWebDriver driver = new RemoteWebDriver(remoteUrl, capabilities); driver.setFileDetector(new LocalFileDetector()); return driver; } else { return new InternetExplorerDriver(capabilities); } }
private void addToInternetExplorerOptionsIfNoEmptyValue(InternetExplorerOptions internetExplorerOptions, String key, String value) { if (isNotEmpty(value)) { internetExplorerOptions.setCapability(key, value); } }
@Override public WebDriver createDriver(Capabilities capabilities) { String driverVersion = (String) capabilities.getCapability(CAPABILITY_DRIVER_VERSION); InternetExplorerDriverManager.getInstance().version(driverVersion).setup(); return new InternetExplorerDriver((InternetExplorerOptions) capabilities); }
@Override public WebDriver getWebDriver(Capabilities capabilities) { return new InternetExplorerDriver(new InternetExplorerOptions(capabilities)); }