use of org.openqa.selenium.ie.InternetExplorerDriver in project jmeter-plugins by undera.
the class InternetExplorerDriverConfigTest method shouldNotStopServiceIfNotRunningWhenQuitBrowserIsInvoked.
@Test
public void shouldNotStopServiceIfNotRunningWhenQuitBrowserIsInvoked() throws Exception {
InternetExplorerDriver mockInternetExplorerDriver = mock(InternetExplorerDriver.class);
InternetExplorerDriverService mockService = mock(InternetExplorerDriverService.class);
when(mockService.isRunning()).thenReturn(false);
config.getServices().put(config.currentThreadName(), mockService);
config.quitBrowser(mockInternetExplorerDriver);
verify(mockInternetExplorerDriver).quit();
assertThat(config.getServices(), is(Collections.<String, InternetExplorerDriverService>emptyMap()));
verify(mockService, times(0)).stop();
}
use of org.openqa.selenium.ie.InternetExplorerDriver in project xwiki-platform by xwiki.
the class WebDriverFactory method createWebDriver.
public XWikiWebDriver createWebDriver(String browserName) {
WebDriver driver;
if (browserName.startsWith("*firefox")) {
// Native events are disabled by default for Firefox on Linux as it may cause tests which open many windows
// in parallel to be unreliable. However, native events work quite well otherwise and are essential for some
// of the new actions of the Advanced User Interaction. We need native events to be enable especially for
// testing the WYSIWYG editor. See http://code.google.com/p/selenium/issues/detail?id=2331 .
FirefoxProfile profile = new FirefoxProfile();
profile.setEnableNativeEvents(true);
// Make sure Firefox doesn't upgrade automatically on CI agents.
profile.setPreference("app.update.auto", false);
profile.setPreference("app.update.enabled", false);
profile.setPreference("app.update.silent", false);
driver = new FirefoxDriver(profile);
// Hide the Add-on bar (from the bottom of the window, with "WebDriver" written on the right) because it can
// prevent buttons or links from being clicked when they are beneath it and native events are used.
// See https://groups.google.com/forum/#!msg/selenium-users/gBozOynEjs8/XDxxQNmUSCsJ
// We need to load a page before sending the keys otherwise WebDriver throws ElementNotVisible exception.
driver.get("data:text/plain;charset=utf-8,XWiki");
driver.switchTo().activeElement().sendKeys(Keys.chord(Keys.CONTROL, "/"));
} else if (browserName.startsWith("*iexplore")) {
driver = new InternetExplorerDriver();
} else if (browserName.startsWith("*chrome")) {
driver = new ChromeDriver();
} else if (browserName.startsWith("*phantomjs")) {
DesiredCapabilities capabilities = DesiredCapabilities.phantomjs();
capabilities.setCapability("handlesAlerts", true);
try {
driver = new PhantomJSDriver(ResolvingPhantomJSDriverService.createDefaultService(), capabilities);
} catch (IOException e) {
throw new RuntimeException(e);
}
} else {
throw new RuntimeException("Unsupported browser name [" + browserName + "]");
}
// Maximize the browser window by default so that the page has a standard layout. Individual tests can resize
// the browser window if they want to test how the page layout adapts to limited space. This reduces the
// probability of a test failure caused by an unexpected layout (nested scroll bars, floating menu over links
// and buttons and so on).
driver.manage().window().maximize();
return new XWikiWebDriver((RemoteWebDriver) driver);
}
use of org.openqa.selenium.ie.InternetExplorerDriver in project selenified by Coveros.
the class TestSetup method setupDriver.
/**
* this creates the webdriver object, which will be used to interact with
* for all browser web tests
*
* @param browser - what browser is being tested on
* @param capabilities - what capabilities are being tested with
* @return WebDriver: the driver to interact with for the test
* @throws InvalidBrowserException If a browser that is not one specified in the
* Selenium.Browser class is used, this exception will be thrown
*/
public static WebDriver setupDriver(Browser browser, DesiredCapabilities capabilities) throws InvalidBrowserException {
WebDriver driver;
// check the browser
switch(browser) {
case HTMLUNIT:
capabilities.setBrowserName("htmlunit");
capabilities.setJavascriptEnabled(true);
System.getProperties().put("org.apache.commons.logging.simplelog.defaultlog", "fatal");
java.util.logging.Logger.getLogger("com.gargoylesoftware.htmlunit").setLevel(Level.OFF);
java.util.logging.Logger.getLogger("org.apache.http").setLevel(Level.OFF);
driver = new HtmlUnitDriver(capabilities);
break;
case FIREFOX:
FirefoxDriverManager.getInstance().forceCache().setup();
FirefoxOptions firefoxOptions = new FirefoxOptions(capabilities);
if (System.getProperty(HEADLESS_INPUT) != null && "true".equals(System.getProperty(HEADLESS_INPUT))) {
firefoxOptions.setHeadless(true);
}
driver = new FirefoxDriver(firefoxOptions);
break;
case CHROME:
ChromeDriverManager.getInstance().forceCache().setup();
ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions = chromeOptions.merge(capabilities);
if (System.getProperty(HEADLESS_INPUT) != null && "true".equals(System.getProperty(HEADLESS_INPUT))) {
chromeOptions.setHeadless(true);
}
driver = new ChromeDriver(chromeOptions);
break;
case INTERNETEXPLORER:
InternetExplorerDriverManager.getInstance().forceCache().setup();
InternetExplorerOptions internetExplorerOptions = new InternetExplorerOptions(capabilities);
driver = new InternetExplorerDriver(internetExplorerOptions);
break;
case EDGE:
EdgeDriverManager.getInstance().forceCache().setup();
EdgeOptions edgeOptions = new EdgeOptions();
edgeOptions = edgeOptions.merge(capabilities);
driver = new EdgeDriver(edgeOptions);
break;
case SAFARI:
SafariOptions safariOptions = new SafariOptions(capabilities);
driver = new SafariDriver(safariOptions);
break;
case OPERA:
OperaDriverManager.getInstance().forceCache().setup();
driver = new OperaDriver(capabilities);
break;
case PHANTOMJS:
PhantomJsDriverManager.getInstance().forceCache().setup();
driver = new PhantomJSDriver(capabilities);
break;
// if the browser is not listed, throw an error
default:
throw new InvalidBrowserException("The selected browser " + browser + " is not an applicable choice");
}
return driver;
}
use of org.openqa.selenium.ie.InternetExplorerDriver in project keycloak by keycloak.
the class URLUtils method navigateToUri.
private static void navigateToUri(String uri, boolean enableIEWorkaround) {
WebDriver driver = getCurrentDriver();
log.info("starting navigation");
// equals the current URL
if (driver instanceof InternetExplorerDriver && driver.getCurrentUrl().equals(uri)) {
log.info("IE workaround: target URL equals current URL - refreshing the page");
driver.navigate().refresh();
waitForPageToLoad();
}
log.info("current URL: " + driver.getCurrentUrl());
log.info("navigating to " + uri);
if (driver.getCurrentUrl().equals(uri)) {
// Some browsers won't do anything if navigating to the same URL; this "fixes" it
log.info("target URL equals current URL - refreshing the page");
driver.navigate().refresh();
} else {
driver.navigate().to(uri);
}
waitForPageToLoad();
log.info("new current URL: " + driver.getCurrentUrl());
// address bar states the correct URL; seemingly this is another bug in IE WebDriver)
if (enableIEWorkaround && driver instanceof InternetExplorerDriver && (driver.getCurrentUrl().matches("^[^#]+/#state=[^#/&]+&code=[^#/&]+$") || driver.getCurrentUrl().matches("^.+/auth/admin/[^/]+/console/$"))) {
log.info("IE workaround: reloading the page after deleting the cookies...");
navigateToUri(uri, false);
} else {
log.info("navigation complete");
}
}
use of org.openqa.selenium.ie.InternetExplorerDriver in project selenium_java by sergueik.
the class IEDriverFactory method newInstance.
@Override
public WebDriver newInstance(DriverOptions driverOptions) {
if (!OS.isFamilyWindows())
throw new UnsupportedOperationException("Unsupported platform: " + Platform.getCurrent());
InternetExplorerDriverService service = setupBuilder(new InternetExplorerDriverService.Builder(), driverOptions, IEDRIVER).build();
InternetExplorerOptions options = newInternetExplorerOptions(driverOptions);
options.merge(driverOptions.getCapabilities());
InternetExplorerDriver driver = new InternetExplorerDriver(service, options);
setInitialWindowSize(driver, driverOptions);
return driver;
}
Aggregations