Example usage for org.openqa.selenium.ie InternetExplorerDriver NATIVE_EVENTS

List of usage examples for org.openqa.selenium.ie InternetExplorerDriver NATIVE_EVENTS

Introduction

In this page you can find the example usage for org.openqa.selenium.ie InternetExplorerDriver NATIVE_EVENTS.

Prototype

String NATIVE_EVENTS

To view the source code for org.openqa.selenium.ie InternetExplorerDriver NATIVE_EVENTS.

Click Source Link

Document

Capability that defines to use whether to use native or javascript events during operations.

Usage

From source file:com.partnet.automation.selenium.AbstractConfigurableDriverProvider.java

License:Apache License

/**
 * Best found default capabilities for Internet Explorer
 * //w  ww . j  av a  2  s .  c  o m
 * @return {@link DesiredCapabilities}
 */
protected DesiredCapabilities getInternetExplorerCapabilities() {
    final DesiredCapabilities capabilities = DesiredCapabilities.internetExplorer();

    // get past certificate security warning pages
    capabilities.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);

    // setup native events and window focus
    // http://jimevansmusic.blogspot.com/2012/06/whats-wrong-with-internet-explorer.html
    capabilities.setCapability(InternetExplorerDriver.NATIVE_EVENTS, true);
    capabilities.setCapability(InternetExplorerDriver.REQUIRE_WINDOW_FOCUS, true);

    // don't accept alerts automatically
    capabilities.setCapability(CapabilityType.UNEXPECTED_ALERT_BEHAVIOUR, false);

    return capabilities;
}

From source file:com.sios.stc.coseng.util.Run.java

License:Open Source License

public synchronized WebDriver getWebDriver(final String testName) throws MalformedURLException {

    WebDriver driver = null;//w  ww. j  a v a 2s.c o  m

    if (testName != null) {

        for (final TestParam p : param.testParam) {
            if (p.getTestName().equals(testName)) {

                // DesiredCapabilities
                // https://code.google.com/p/selenium/wiki/DesiredCapabilities

                // !! It is *not* necessary to start *any* of the browser driver
                // profiles to start 'private/icognito' as each new driver
                // instance starts with a *fresh* profile that does not persist
                // after the driver is quit. !!

                if (p.getBrowser().equals(Browser.FIREFOX)) {
                    final FirefoxProfile profile = new FirefoxProfile();
                    final DesiredCapabilities dc = DesiredCapabilities.firefox();
                    if (p.getPlatform().equals(Platform.LINUX)) {
                        // Explicitly enable native events(this is mandatory on Linux system,
                        // since they are not enabled by default.
                        profile.setEnableNativeEvents(true);
                        dc.setPlatform(p.getPlatform());
                        dc.setCapability(Common.BROWSER_CAPABILITY_FIREFOX_PROFILE, profile);
                    }
                    if (p.getSpot().equals(Spot.LOCAL)) {
                        driver = new FirefoxDriver(profile);
                    } else {
                        driver = new RemoteWebDriver(new URL(p.getSeleniumGridUrl()), dc);
                    }
                } else if (p.getBrowser().equals(Browser.CHROME)) {
                    final DesiredCapabilities dc = DesiredCapabilities.chrome();
                    dc.setPlatform(p.getPlatform());
                    if (p.getSpot().equals(Spot.LOCAL)) {
                        driver = new ChromeDriver();
                    } else {
                        driver = new RemoteWebDriver(new URL(p.getSeleniumGridUrl()), dc);
                    }
                } else if (p.getBrowser().toString().toLowerCase().startsWith("ie")) {
                    final DesiredCapabilities dc = DesiredCapabilities.internetExplorer();
                    dc.setBrowserName(Common.BROWSER_NAME_INTERNET_EXPLORER);
                    dc.setPlatform(p.getPlatform());
                    // IE8 and newer; Make sure
                    // HKEY_USERS\.Default\Software\Microsoft\Internet
                    // Explorer has DWORD TabProcGrowth set 0
                    // Launch separate process in 'private' mode.
                    dc.setCapability(InternetExplorerDriver.FORCE_CREATE_PROCESS, true);
                    dc.setCapability(InternetExplorerDriver.IE_SWITCHES, "-private");
                    //dc.setCapability(InternetExplorerDriver.LOG_FILE,
                    //        "C:/iedriver.log");
                    //dc.setCapability(InternetExplorerDriver.LOG_LEVEL,
                    //        "DEBUG");
                    dc.setCapability(InternetExplorerDriver.NATIVE_EVENTS, true);
                    // dc.setCapability(
                    // InternetExplorerDriver.REQUIRE_WINDOW_FOCUS,
                    // true);

                    // If *is* a specific IE9, IE10, IE11 (not IE) set the version
                    if (!p.getBrowser().equals(Browser.IE)) {
                        dc.setVersion(p.getBrowser().getVersion());
                    }

                    if (p.getSpot().equals(Spot.LOCAL)) {
                        driver = new InternetExplorerDriver();
                    } else {
                        driver = new RemoteWebDriver(new URL(p.getSeleniumGridUrl()), dc);
                    }
                }
            }
            // Collect the driver for quit after tests complete
            if (driver != null) {
                collectDriver(driver);
            }
        }
    }
    return driver;
}

From source file:org.me.seleniumGridUI.SeleniumGridOperation.java

public static DesiredCapabilities CreateBrowserCapbility(String browser) {
    DesiredCapabilities caps = null;/*from  ww w. j av a  2s  .  c  o m*/
    if (browser.equalsIgnoreCase("firefox")) {
        caps = DesiredCapabilities.firefox();
    } else if (browser.equalsIgnoreCase("chrome")) {
        caps = DesiredCapabilities.chrome();
        ChromeOptions options = new ChromeOptions();
        options.addArguments("disable-popup-blocking");
        options.addArguments("disable-prompt-on-repost");
        options.addArguments("whitelist-ips");
        options.addArguments("no-first-run");
        options.addArguments("disk-cache-size=1");
        options.addArguments("media-cache-size=1");
        options.addArguments("test-type");
        caps.setCapability(ChromeOptions.CAPABILITY, options);
    } else if (browser.equalsIgnoreCase("ie")) {
        caps = DesiredCapabilities.internetExplorer();
        caps.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true);
        caps.setCapability(InternetExplorerDriver.REQUIRE_WINDOW_FOCUS, true);
        caps.setCapability(InternetExplorerDriver.IGNORE_ZOOM_SETTING, true);
        caps.setCapability(InternetExplorerDriver.ENABLE_ELEMENT_CACHE_CLEANUP, true);
        caps.setCapability(InternetExplorerDriver.NATIVE_EVENTS, false);
        caps.setCapability(InternetExplorerDriver.UNEXPECTED_ALERT_BEHAVIOR, UnexpectedAlertBehaviour.DISMISS);
    } else if (browser.equalsIgnoreCase("phantomjs")) {
        caps = DesiredCapabilities.phantomjs();
    } else if (browser.equalsIgnoreCase("safari")) {
        caps = DesiredCapabilities.safari();
    } else if (browser.equalsIgnoreCase("iphone")) {
        caps = DesiredCapabilities.iphone();
    } else if (browser.equalsIgnoreCase("ipad")) {
        caps = DesiredCapabilities.ipad();
    } else {
        caps = DesiredCapabilities.htmlUnit();
    }
    return caps;
}