Java Code Examples for org.openqa.selenium.ie.InternetExplorerDriver

The following are top voted examples for showing how to use org.openqa.selenium.ie.InternetExplorerDriver. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: java-maven-selenium   File: DriverFactory.java   Source Code and License 8 votes vote down vote up
public static WebDriver getDriver() {

        String browser = System.getenv("BROWSER");
        if (browser == null) {
            ChromeDriverManager.getInstance().setup();
            return new ChromeDriver();
        }
        switch (browser)
        {
            case "IE":
                InternetExplorerDriverManager.getInstance().setup();
                return new InternetExplorerDriver();
            case "FIREFOX":
                FirefoxDriverManager.getInstance().setup();
                return new FirefoxDriver();
            default:
                ChromeDriverManager.getInstance().setup();
                return new ChromeDriver();

        }
    }
 
Example 2
Project: selenium-cucumber-framework   File: BrowserFactory.java   Source Code and License 7 votes vote down vote up
public static WebDriver selectLocalBrowser() {
	switch (browser) {
	case Chrome:
		return new ChromeDriver();
	case Firefox:
		return new FirefoxDriver();
	case IE:
		return new InternetExplorerDriver();
	case Opera:
		return new OperaDriver();
	case Safari:
		return new SafariDriver();
	default:
		throw new WebDriverException("No browser specified");
	}
}
 
Example 3
Project: SwiftLite   File: WebDriverFactory.java   Source Code and License 7 votes vote down vote up
@Override
public WebDriver create() {
	DesiredCapabilities ieCapabilities = DesiredCapabilities.internetExplorer();		
	ieCapabilities.setCapability("unexpectedAlertBehaviour" , "ignore");
	//ieCapabilities.setCapability("enablePersistentHover", true);
	//TM:22/01/2014- Added following for GAIC
	ieCapabilities
	.setCapability(
			InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS,
			true);// Add this desiredcapabilities when the security
					// level of IE not set to same.
	ieCapabilities.setBrowserName("SELENIUM");
	ieCapabilities.setJavascriptEnabled(true);
	ieCapabilities.setCapability("browserstack.ie.enablePopups", "true");
	ieCapabilities.setCapability("acceptSslCerts", "true");
	// ieCapabilities.setCapability("browserstack.ie.noFlash", "true");
	File file = new File(System.getProperty("user.dir") + "//exe//IEDriverServer.exe");
	System.setProperty("webdriver.ie.driver", file.getAbsolutePath());
	return new InternetExplorerDriver(ieCapabilities);
}
 
Example 4
Project: SWET   File: BrowserDriver.java   Source Code and License 6 votes vote down vote up
private static DesiredCapabilities capabilitiesInternetExplorer() {

		DesiredCapabilities capabilities = DesiredCapabilities.internetExplorer();
		final String ieDriverPath = (applicationIeDriverPath == null)
				? "c:/java/selenium/IEDriverServer.exe" : applicationIeDriverPath;
		System.setProperty("webdriver.ie.driver", ieDriverPath
		/* (new File(ieDriverPath)).getAbsolutePath() */);
		capabilities.setCapability(
				InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS,
				true);
		capabilities.setCapability("ignoreZoomSetting", true);
		capabilities.setCapability("ignoreProtectedModeSettings", true);
		capabilities.setCapability("requireWindowFocus", true);
		capabilities.setBrowserName(
				DesiredCapabilities.internetExplorer().getBrowserName());
		return capabilities;
	}
 
Example 5
Project: AutomationFrameworkTPG   File: DriverProperties.java   Source Code and License 6 votes vote down vote up
private WebDriver initIEDriver(String appURL) {
	System.out.println("Launching IE browser..");
	DesiredCapabilities ieCapabilities = DesiredCapabilities.internetExplorer();
	ieCapabilities.setJavascriptEnabled(true); 
	ieCapabilities.setCapability(CapabilityType.ACCEPT_SSL_CERTS,   
			true); 
	ieCapabilities.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS,true); 
	ieCapabilities.setCapability(InternetExplorerDriver.IGNORE_ZOOM_SETTING,true);         
	ieCapabilities.setCapability(CapabilityType.UNEXPECTED_ALERT_BEHAVIOUR,UnexpectedAlertBehaviour.DISMISS); //Accept unexpected alerts 
	ieCapabilities.setCapability("requireWindowFocus", true); 
	ieCapabilities.setCapability("enablePersistentHover", false); 
	ieCapabilities.setCapability(CapabilityType.ForSeleniumServer.ENSURING_CLEAN_SESSION, true);
	
	WebDriver driver=new InternetExplorerDriver(ieCapabilities);
	driver.manage().deleteAllCookies();
    driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
    for(String winHandle : driver.getWindowHandles()){
       driver =  driver.switchTo().window(winHandle);
    }
    driver.get(appURL);
	return new WebDriverProxy().protect(driver);
}
 
Example 6
Project: Spring-Security-Third-Edition   File: SeleniumTestUtilities.java   Source Code and License 6 votes vote down vote up
public static WebDriver getEdgeDriver()
{
	String path = System.getProperty("user.dir") + "\\Drivers\\EdgeWebDriver.exe";
	System.setProperty("webdriver.ie.driver", path);
	DesiredCapabilities caps = DesiredCapabilities.internetExplorer();
	caps.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS,	true);
	return new InternetExplorerDriver(caps);
}
 
Example 7
Project: Spring-Security-Third-Edition   File: SeleniumTestUtilities.java   Source Code and License 6 votes vote down vote up
public static WebDriver get32IEDriver()
{
	String path = System.getProperty("user.dir") + "\\Drivers\\IEDriverServer32.exe";
	System.setProperty("webdriver.ie.driver", path);
	DesiredCapabilities caps = DesiredCapabilities.internetExplorer();
	caps.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS,	true);
	return new InternetExplorerDriver(caps);
}
 
Example 8
Project: Spring-Security-Third-Edition   File: SeleniumTestUtilities.java   Source Code and License 6 votes vote down vote up
public static WebDriver get64IEDriver()
{
	String path = System.getProperty("user.dir") + "\\Drivers\\IEDriverServer64.exe";
	System.setProperty("webdriver.ie.driver", path);
	DesiredCapabilities caps = DesiredCapabilities.internetExplorer();
	caps.setCapability(CapabilityType.BROWSER_NAME, "IE");
	caps.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS,	true);

	return new InternetExplorerDriver(caps);
}
 
Example 9
Project: apache-archiva   File: WebDriverBrowseTest.java   Source Code and License 6 votes vote down vote up
@Override
public WebDriver getDefaultDriver()
{
    String seleniumBrowser = System.getProperty( "selenium.browser" );

    if ( StringUtils.contains( seleniumBrowser, "chrome" ) )
    {
        return new ChromeDriver();
    }

    if ( StringUtils.contains( seleniumBrowser, "safari" ) )
    {
        return new SafariDriver();
    }

    if ( StringUtils.contains( seleniumBrowser, "iexplore" ) )
    {
        return new InternetExplorerDriver();
    }
    
    return new FirefoxDriver();

}
 
Example 10
Project: apache-archiva   File: WebDriverTest.java   Source Code and License 6 votes vote down vote up
@Override
public WebDriver getDefaultDriver()
{
    String seleniumBrowser = System.getProperty( "selenium.browser" );

    if ( StringUtils.contains( seleniumBrowser, "chrome" ) )
    {
        return new ChromeDriver();
    }

    if ( StringUtils.contains( seleniumBrowser, "safari" ) )
    {
        return new SafariDriver();
    }

    if ( StringUtils.contains( seleniumBrowser, "iexplore" ) )
    {
        return new InternetExplorerDriver();
    }

    return new FirefoxDriver();

}
 
Example 11
Project: chr-krenn-fhj-ws2016-sd14-pse   File: BaseUITest.java   Source Code and License 6 votes vote down vote up
WebDriver start(Capabilities capabilities) {
    switch (this) {
        case FIREFOX:
            return new FirefoxDriver(capabilities);
        case HTML_UNIT:
            return new HtmlUnitDriver(capabilities);
        case CHROME:
            return new ChromeDriver(capabilities);
        case EDGE:
            return new EdgeDriver(capabilities);
        case INTERNET_EXPLORER:
            return new InternetExplorerDriver(capabilities);
        case SAFARI:
            return new SafariDriver(capabilities);
        default:
            throw new AssertionError();
    }
}
 
Example 12
Project: g2   File: WebDriverFactoryTest.java   Source Code and License 6 votes vote down vote up
@Test
public void buildWebDriver() throws Exception {
	MockitoAnnotations.initMocks(this);

	PowerMockito.whenNew(FirefoxDriver.class).withNoArguments().thenReturn(firefoxDriver);
	WebDriver driver = WebDriverFactory.createDriver("firefox");
	assertThat(driver).isInstanceOf(FirefoxDriver.class);

	PowerMockito.whenNew(InternetExplorerDriver.class).withNoArguments().thenReturn(internetExplorerDriver);
	driver = WebDriverFactory.createDriver("ie");
	assertThat(driver).isInstanceOf(InternetExplorerDriver.class);

	PowerMockito.whenNew(ChromeDriver.class).withNoArguments().thenReturn(chromerDriver);
	driver = WebDriverFactory.createDriver("chrome");
	assertThat(driver).isInstanceOf(ChromeDriver.class);

	PowerMockito.whenNew(RemoteWebDriver.class)
			.withArguments(new URL("http://localhost:4444/wd/hub"), DesiredCapabilities.firefox())
			.thenReturn(remoteWebDriver);
	driver = WebDriverFactory.createDriver("remote:localhost:4444:firefox");
	assertThat(driver).isInstanceOf(RemoteWebDriver.class);
}
 
Example 13
Project: learn_selenium2   File: SeleniumDriver.java   Source Code and License 6 votes vote down vote up
private WebDriver initDriver() {
	if ("firefox".equals(Config.Browser)) {
		driver = new FirefoxDriver();
	} else if ("ie".equals(Config.Browser)) {
		System.setProperty("webdriver.ie.driver",
				"files/IEDriverServer.exe");
		driver = new InternetExplorerDriver();
	} else if ("chrome".equals(Config.Browser)) {
		System.setProperty("webdriver.chrome.driver",
				"files/chromedriver.exe");
		driver = new ChromeDriver();
		// Navigation navigation = driver.navigate();
		// navigation.to("https://www.baidu.com");
	} else {
		System.out.println("浏览器匹配值错误" + Config.Browser);
	}
	driver.manage().window().maximize();
	driver.manage().timeouts()
			.pageLoadTimeout(Config.waitTime, TimeUnit.SECONDS);
	return driver;
}
 
Example 14
Project: seleniumtestsframework   File: IEDriverFactory.java   Source Code and License 6 votes vote down vote up
@Override
public WebDriver createWebDriver() throws IOException {

    // killProcess();
    if (!OSUtility.isWindows()) {
        throw new RuntimeException("With gods grace IE browser is only supported on windows, Imagine a "
                + "situation when you have to fix IE bugs on Unix and Mac as well");
    }

    DriverConfig cfg = this.getWebDriverConfig();

    driver = new InternetExplorerDriver(new IECapabilitiesFactory().createCapabilities(cfg));

    // Implicit Waits to handle dynamic element. The default value is 5 seconds.
    setImplicitWaitTimeout(cfg.getImplicitWaitTimeout());
    if (cfg.getPageLoadTimeout() >= 0) {
        driver.manage().timeouts().pageLoadTimeout(cfg.getPageLoadTimeout(), TimeUnit.SECONDS);
    }

    this.setWebDriver(driver);
    return driver;
}
 
Example 15
Project: java-gradle-selenium   File: DriverFactory.java   Source Code and License 6 votes vote down vote up
@BeforeSuite
public void Setup() {
    // Uses chrome driver by default
    String browser = System.getenv("BROWSER");
    if (browser == null) {
        browser = DEFAULT;
    }

    if (browser.toLowerCase().equals(FIREFOX)) {
        FirefoxDriverManager.getInstance().setup();
        driver = new FirefoxDriver();
    } else if (browser.toLowerCase().equals(IE)) {
        InternetExplorerDriverManager.getInstance().setup();
        driver = new InternetExplorerDriver();
    } else {
        ChromeDriverManager.getInstance().setup();
        driver = new ChromeDriver();
    }
}
 
Example 16
Project: seauto   File: AbstractConfigurableDriverProvider.java   Source Code and License 6 votes vote down vote up
/**
 * Default implementation of getting a local Internet Explorer web driver.
 * 
 * @return the WebDriver
 */
protected WebDriver getInternetExplorerWebDriver()
{
  // Note: running ie9 32 bit driver is faster then 64 bit driver. Download
  // the preferred IEDriverServer.exe from selenium's website
  LOG.debug("Start IE");

  // Note: this driver is only used when running the tests locally in IE
  String ieDriverPath = getOsSpecificBinaryPathFromProp(IE_DRIVER_BIN_PROP, "IEDriverServer");

  if (StringUtils.isNotBlank(ieDriverPath) && doesFileExist(ieDriverPath)) {
    LOG.info("Use specified IE Driver path: {}", ieDriverPath);
    System.setProperty("webdriver.ie.driver", ieDriverPath);
  }
  else {
    LOG.debug("Use default IEDriverServer.exe location");
  }

  return new InternetExplorerDriver(getInternetExplorerCapabilities());
}
 
Example 17
Project: seauto   File: AbstractConfigurableDriverProvider.java   Source Code and License 6 votes vote down vote up
/**
 * Best found default capabilities for Internet Explorer
 * 
 * @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;
}
 
Example 18
Project: wtf-core   File: WTFTest.java   Source Code and License 6 votes vote down vote up
public synchronized WebDriver getDriver(WTFBrowser browser, WTFCountry country,
		ITestResult testResult) {
	switch (browser) {
	case FIREFOX:
		return new FirefoxDriver(loadFirefoxProfile(country));
	case IE:
		setIEDriverService();
		return new InternetExplorerDriver();
	case CHROME:
		setChromeDriverService();
		return new ChromeDriver();
	case OPERA:
		return new OperaDriver();
	default:
		// TOSO (vsundramurthy) Throw invalid browser exception..
		return null;
	}
}
 
Example 19
Project: wisard   File: BrowserDriver.java   Source Code and License 6 votes vote down vote up
boolean initIE(String url, String path) {
    //IE
    try {
        System.setProperty("webdriver.ie.driver", path);
        driver = new InternetExplorerDriver();
        js = (JavascriptExecutor) driver;
        writer.writeHeader(url, "IE");
        driver.get(url);
    } catch (IllegalStateException ise) {
        ui.errorMessage("Path to IE driver is invalid, check settings.");
        return false;
    } catch (InvalidArgumentException iae) {
        ui.errorMessage("Invalid URL?");
        return false;
    } catch (Exception e) {
        System.err.println(e);
        return false;
    }
    return true;
}
 
Example 20
Project: Swd.StarterJ   File: WebDriverRunner.java   Source Code and License 6 votes vote down vote up
private WebDriver startEmbededWebDriver(String browserType) {
    switch (browserType) {
        case BROWSER_FIREFOX:
            return new FirefoxDriver();
        case BROWSER_CHROME:
            return new ChromeDriver();
        case BROWSER_IE:
            return new InternetExplorerDriver();
         case BROWSER_SAFARI:
            return new SafariDriver();
        default:
            String errorMessage = String.format(
                    "browserType: <%s> was not recognized as supported browser."
                    + " This parameter is case sensitive", browserType);
            throw new IllegalArgumentException(errorMessage);
    }
}
 
Example 21
Project: selenium-java-robot   File: LocalRobotizedBrowserFactory.java   Source Code and License 6 votes vote down vote up
public static LocalRobotizedBrowserFactory createRobotizedWebDriverFactory(String browser) {
    if (BrowserType.FIREFOX.equalsIgnoreCase(browser)) {
        FirefoxProfile firefoxProfile = null;
        String firefoxProfileProperty = System.getProperty("webdriver.firefox.profile");
        if (firefoxProfileProperty == null) {
            ProfilesIni allProfiles = new ProfilesIni();
            // Use the default profile to make extensions available,
            // and especially to ease debugging with Firebug
            firefoxProfile = allProfiles.getProfile("default");
        }
        return new LocalFirefox(firefoxProfile);
    } else if (BrowserType.SAFARI.equalsIgnoreCase(browser)) {
        return new LocalSafari();
    } else if (BrowserType.CHROME.equalsIgnoreCase(browser)) {
        return new LocalBrowser<ChromeDriver>(ChromeDriver.class);
    } else if ("chrome-debug".equalsIgnoreCase(browser)) {
        return new LocalDebuggableChrome();
    } else if (BrowserType.IE.equalsIgnoreCase(browser)) {
        return new LocalBrowser<InternetExplorerDriver>(InternetExplorerDriver.class);
    } else {
        throw new RuntimeException("Unknown browser value: " + browser);
    }

}
 
Example 22
Project: web-test   File: WebDriverUtilsTest.java   Source Code and License 6 votes vote down vote up
@Test
public void saveScreenshotIETest() {
	if(System.getProperty("webdriver.ie.driver") == null) {
		throw new SkipException("The path to the driver executable (webdriver.ie.driver) is not set");
	}
	
	WebDriverFactory wdf = new WebDriverFactory("internet explorer");
	DesiredCapabilities capabilities = new DesiredCapabilities();
	capabilities.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true);
	WebDriver wd = wdf.createDriver(capabilities);
	wd.get("http://google.com");
	File screenshotFile = WebDriverUtils.saveScreenshot(wd, getScreenshotName("ie"));
	wd.quit();
	
	assertThat(screenshotFile.exists(), equalTo(true));
	
   	if(Boolean.parseBoolean(System.getProperty("org.uncommons.reportng.escape-output", "true"))) {
   		Reporter.log("Screenshot: " + screenshotFile.getAbsolutePath());
   	} else {
   		Reporter.log("<a href=\"file:///" + screenshotFile.getAbsolutePath() + "\">Screenshot</a>");
   	}	
}
 
Example 23
Project: gga-selenium-framework   File: SeleniumDriverFactory.java   Source Code and License 6 votes vote down vote up
private String registerLocalDriver(DriverTypes driverType) {
    DesiredCapabilities capabilities;
    switch (driverType) {
        case CHROME:
            setProperty("webdriver.chrome.driver", getDriversPath() + "chromedriver.exe");
            return registerDriver(driverType,
                    () -> webDriverSettings.apply(new ChromeDriver()));
        case FIREFOX:
            return registerDriver(driverType,
                    () -> webDriverSettings.apply(new FirefoxDriver()));
        case IE:
            capabilities = internetExplorer();
            capabilities.setCapability(INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true);
            setProperty("webdriver.ie.driver", getDriversPath() + "IEDriverServer.exe");
            return registerDriver(driverType,
                    () -> webDriverSettings.apply(new InternetExplorerDriver(capabilities)));
    }
    throw exception("Unknown driver: " + driverType);
}
 
Example 24
Project: appengine   File: WebDriverFactoryTest.java   Source Code and License 6 votes vote down vote up
@Test
public void buildWebDriver() throws Exception {
	MockitoAnnotations.initMocks(this);

	PowerMockito.whenNew(FirefoxDriver.class).withNoArguments().thenReturn(firefoxDriver);
	WebDriver driver = WebDriverFactory.createDriver("firefox");
	assertTrue(driver instanceof FirefoxDriver);

	PowerMockito.whenNew(InternetExplorerDriver.class).withNoArguments().thenReturn(internetExplorerDriver);
	driver = WebDriverFactory.createDriver("ie");
	assertTrue(driver instanceof InternetExplorerDriver);

	PowerMockito.whenNew(ChromeDriver.class).withNoArguments().thenReturn(chromerDriver);
	driver = WebDriverFactory.createDriver("chrome");
	assertTrue(driver instanceof ChromeDriver);

	PowerMockito.whenNew(HtmlUnitDriver.class).withArguments(true).thenReturn(htmlUnitDriver);
	driver = WebDriverFactory.createDriver("htmlunit");
	assertTrue(driver instanceof HtmlUnitDriver);

	PowerMockito.whenNew(RemoteWebDriver.class)
			.withArguments(new URL("http://localhost:4444/wd/hub"), DesiredCapabilities.firefox())
			.thenReturn(remoteWebDriver);
	driver = WebDriverFactory.createDriver("remote:localhost:4444:firefox");
	assertTrue(driver instanceof RemoteWebDriver);
}
 
Example 25
Project: candybean   File: InternetExplorerInterface.java   Source Code and License 6 votes vote down vote up
@Override
public void start() throws CandybeanException {
	DesiredCapabilities capabilities = new DesiredCapabilities();
	String ieDriverPath = candybean.config.getPathValue("browser.ie.driver.path");
	if(StringUtils.isEmpty(ieDriverPath) || !new File(ieDriverPath).exists()){
		String error = "Unable to find internet explorer driver from the specified location("+ieDriverPath+") in the configuration file! \n"
				+ "Please add a configuration to the candybean config file for key \"browser.ie.driver.path\" "
				+ "that indicates the absolute location the driver.";
		logger.severe(error);
		throw new CandybeanException(error);
	}else{
		logger.info("ieDriverPath: " + ieDriverPath);
		System.setProperty("webdriver.ie.driver", ieDriverPath);
		capabilities = DesiredCapabilities.internetExplorer();
		super.wd = new InternetExplorerDriver(capabilities);
        super.start(); // requires wd to be instantiated first
	}
}
 
Example 26
Project: at.info-knowledge-base   File: upload_file.java   Source Code and License 6 votes vote down vote up
static public void main(String[] args) {
	// Creating webdriver
	System.setProperty("webdriver.ie.driver", "C:\\WORK\\IEDriverServer_Win32_2.37.0\\IEDriverServer.exe");
	WebDriver driver = new InternetExplorerDriver();

// Opening page. In this case - local HTML file.
   	driver.get("file://C:/WORK/test.html");

   	// Find element that uploads file.
   	WebElement fileInput = driver.findElement(By.id("file"));

   	// Set direct path to local file that needs to be uploaded. 
   	// That also can be a direct link to file in web, like - https://www.google.com.ua/images/srpr/logo11w.png
   	fileInput.sendKeys("file://C:/WORK/lenna.png");

   	// find button that sends form and click it.
   	driver.findElement(By.id("submit")).click();

   	// Closing driver and session
   	driver.quit();
}
 
Example 27
Project: galen   File: SeleniumBrowserFactory.java   Source Code and License 6 votes vote down vote up
public static WebDriver getDriver(String browserType){
    
    if ( StringUtils.isEmpty(browserType) || FIREFOX.equals(browserType)) {
        return new FirefoxDriver(SeleniumBrowserFactory.getBrowserCapabilities(browserType));
    }
    else if (CHROME.equals(browserType)) {
        return new ChromeDriver(SeleniumBrowserFactory.getBrowserCapabilities(browserType));
    }
    else if (IE.equals(browserType)) {
        return new InternetExplorerDriver(SeleniumBrowserFactory.getBrowserCapabilities(browserType));
    }
    else if (PHANTOMJS.equals(browserType)) {
        return new PhantomJSDriver();
    }
    else if (SAFARI.equals(browserType)) {
        return new SafariDriver();
    }
    else if (EDGE.equals(browserType)) {
        return new EdgeDriver();
    }
    else {
        throw new RuntimeException(String.format("Unknown browser type: \"%s\"", browserType));
    }
}
 
Example 28
Project: SeleniumFramework   File: Browser.java   Source Code and License 6 votes vote down vote up
/**
 * This method initialises the ThreadLocal WebDriver object according to the
 * supplied parameters to enable tests to run on a users local machine.
 */
private void setLocalWebdriver() {

    DesiredCapabilities capabilities = new DesiredCapabilities();
    capabilities.setJavascriptEnabled(true);
    capabilities.setCapability("handlesAlerts", true);
    switch (getBrowserId(browser)) {
        case 0:
            capabilities.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS,
                    Boolean.valueOf(System.getProperty("IGNORE_SECURITY_DOMAINS", "false")));
            driver.set(new InternetExplorerDriver(capabilities));
            break;
        case 1:
            driver.set(new FirefoxDriver(capabilities));
            break;
        case 2:
            driver.set(new SafariDriver(capabilities));
            break;
        case 3:
            driver.set(new ChromeDriver(capabilities));
            break;
        default:
            throw new WebDriverException("Browser not found: " + browser);
    }
}
 
Example 29
Project: SeleniumFramework   File: BaseTest.java   Source Code and License 6 votes vote down vote up
/**
 * This method initialises the ThreadLocal WebDriver object according to the
 * supplied parameters to enable tests to run on a users local machine.
 *
 * @param browser  This can be set to "chrome", "internet explorer" or "firefox"
 * @param version  This should be set to reflect the browser required. It is only
 *                 used when matching capabilities for a RemoteWebDriver object
 *                 however.
 * @param platform This should be set to whatever platform the test is required
 *                 to run on e.g. "WINDOWS", "MAC", "LINUX". It is only used when
 *                 matching capabilities for a RemoteWebDriver object however.
 */
public void setLocalWebdriver(String browser, String version,
                              String platform) {

    DesiredCapabilities capabilities = new DesiredCapabilities();
    capabilities.setJavascriptEnabled(true);
    capabilities.setCapability("handlesAlerts", true);
    switch (getBrowserId(browser)) {
        case 0:
            capabilities.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS,
                    Boolean.valueOf(System.getProperty("IGNORE_SECURITY_DOMAINS", "false")));
            driver.set(new InternetExplorerDriver(capabilities));
            break;
        case 1:
            driver.set(new FirefoxDriver(capabilities));
            break;
        case 2:
            driver.set(new SafariDriver(capabilities));
            break;
        case 3:
            driver.set(new ChromeDriver(capabilities));
            break;
        default:
            throw new WebDriverException("Browser not found: " + browser);
    }
}
 
Example 30
Project: teasy   File: SeleniumTestExecutionListener.java   Source Code and License 5 votes vote down vote up
private WebDriver explorer(DesiredCapabilities customDesiredCapabilities) {
    InternetExplorerDriverManager.getInstance().version(STABLE_IE_DRIVER_VERSION).setup();
    DesiredCapabilities desiredCapabilities = getIEDesiredCapabilities();
    if (!customDesiredCapabilities.asMap().isEmpty()) {
        desiredCapabilities.merge(customDesiredCapabilities);
    }
    return new InternetExplorerDriver(desiredCapabilities);
}
 
Example 31
Project: teasy   File: SeleniumTestExecutionListener.java   Source Code and License 5 votes vote down vote up
private WebDriver explorer(String version, DesiredCapabilities customDesiredCapabilities) {
    InternetExplorerDriverManager.getInstance().version(STABLE_IE_DRIVER_VERSION).setup();
    DesiredCapabilities desiredCapabilities = getIEDesiredCapabilities(version);
    if (!customDesiredCapabilities.asMap().isEmpty()) {
        desiredCapabilities.merge(customDesiredCapabilities);
    }
    return new InternetExplorerDriver(desiredCapabilities);
}
 
Example 32
Project: teasy   File: SeleniumTestExecutionListener.java   Source Code and License 5 votes vote down vote up
private DesiredCapabilities getIEDesiredCapabilities() {
    DesiredCapabilities capabilities = DesiredCapabilities.internetExplorer();
    capabilities.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true);
    capabilities.setCapability(InternetExplorerDriver.IE_SWITCHES, "-private");
    capabilities.setCapability(InternetExplorerDriver.FORCE_CREATE_PROCESS, true);
    capabilities.setCapability(InternetExplorerDriver.IE_ENSURE_CLEAN_SESSION, true);
    capabilities.setCapability(CapabilityType.SUPPORTS_ALERTS, true);
    capabilities.setPlatform(Platform.WINDOWS);
    capabilities.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
    setAlertBehaviorCapabilities(capabilities);
    setProxy(capabilities);
    //Found that setting this capability could increase IE tests speed. Should be checked.
    capabilities.setCapability(InternetExplorerDriver.REQUIRE_WINDOW_FOCUS, true);
    return capabilities;
}
 
Example 33
Project: phoenix.webui.framework   File: CapabilityConfig.java   Source Code and License 5 votes vote down vote up
/**
 * ie浏览器
 */
private void ie()
{
	String initialUrl = enginePro.getProperty(DriverConstants.INITIAL_URL,
			"http://surenpi.com");
	
	DesiredCapabilities capability = DesiredCapabilities.internetExplorer();
	capability.setCapability(
			InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true);
	capability.setCapability(InternetExplorerDriver.INITIAL_BROWSER_URL, initialUrl);
	capability.setCapability(InternetExplorerDriver.REQUIRE_WINDOW_FOCUS, false);
	engineCapMap.put(DRIVER_IE, capability);
}
 
Example 34
Project: NoraUi   File: DriverFactory.java   Source Code and License 5 votes vote down vote up
/**
 * Generates an ie webdriver. Unable to use it with a proxy. Causes a crash.
 *
 * @return
 *         An ie webdriver
 * @throws TechnicalException
 *             if an error occured when Webdriver setExecutable to true.
 */
private WebDriver generateIEDriver() throws TechnicalException {
    final String pathWebdriver = DriverFactory.getPath(Driver.IE);
    if (!new File(pathWebdriver).setExecutable(true)) {
        throw new TechnicalException(Messages.getMessage(TechnicalException.TECHNICAL_ERROR_MESSAGE_WEBDRIVER_SET_EXECUTABLE));
    }
    logger.info("Generating IE driver ({}) ...", pathWebdriver);

    System.setProperty(Driver.IE.getDriverName(), pathWebdriver);

    final DesiredCapabilities capabilities = DesiredCapabilities.internetExplorer();
    capabilities.setCapability(InternetExplorerDriver.IE_ENSURE_CLEAN_SESSION, true);
    capabilities.setCapability(InternetExplorerDriver.IGNORE_ZOOM_SETTING, true);
    capabilities.setCapability(InternetExplorerDriver.REQUIRE_WINDOW_FOCUS, true);
    capabilities.setCapability(InternetExplorerDriver.NATIVE_EVENTS, false);
    capabilities.setCapability(CapabilityType.UNEXPECTED_ALERT_BEHAVIOUR, UnexpectedAlertBehaviour.ACCEPT);
    capabilities.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true);
    capabilities.setCapability("disable-popup-blocking", true);
    capabilities.setJavascriptEnabled(true);

    setLoggingLevel(capabilities);

    // Proxy configuration
    if (Context.getProxy().getProxyType() != ProxyType.UNSPECIFIED && Context.getProxy().getProxyType() != ProxyType.AUTODETECT) {
        capabilities.setCapability(CapabilityType.PROXY, Context.getProxy());
    }

    return new InternetExplorerDriver(capabilities);
}
 
Example 35
Project: Java-Testing-Toolbox   File: InternetExplorerConfiguration.java   Source Code and License 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public InternetExplorerDriver start(Capabilities other) {
    Capabilities capabilities = this.mergeCapabilities(other);

    if (capabilities == null) {
        return new InternetExplorerDriver();
    }

    return new InternetExplorerDriver(capabilities);
}
 
Example 36
Project: Spring-Security-Third-Edition   File: SeleniumTestUtilities.java   Source Code and License 5 votes vote down vote up
public static WebDriver get32IEDriver()
{
	String path = System.getProperty("user.dir") + "\\Drivers\\IEDriverServer32.exe";
	System.setProperty("webdriver.ie.driver", path);
	DesiredCapabilities caps = DesiredCapabilities.internetExplorer();
	caps.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS,	true);
	return new InternetExplorerDriver(caps);
}
 
Example 37
Project: Spring-Security-Third-Edition   File: SeleniumTestUtilities.java   Source Code and License 5 votes vote down vote up
public static WebDriver get64IEDriver()
{
	String path = System.getProperty("user.dir") + "\\Drivers\\IEDriverServer64.exe";
	System.setProperty("webdriver.ie.driver", path);
	DesiredCapabilities caps = DesiredCapabilities.internetExplorer();
	caps.setCapability(CapabilityType.BROWSER_NAME, "IE");
	caps.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS,	true);

	return new InternetExplorerDriver(caps);
}
 
Example 38
Project: Spring-Security-Third-Edition   File: SeleniumTestUtilities.java   Source Code and License 5 votes vote down vote up
public static WebDriver getEdgeDriver()
{
	String path = System.getProperty("user.dir") + "\\Drivers\\EdgeWebDriver.exe";
	System.setProperty("webdriver.ie.driver", path);
	DesiredCapabilities caps = DesiredCapabilities.internetExplorer();
	caps.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS,	true);
	return new InternetExplorerDriver(caps);
}
 
Example 39
Project: Spring-Security-Third-Edition   File: SeleniumTestUtilities.java   Source Code and License 5 votes vote down vote up
public static WebDriver get32IEDriver()
{
	String path = System.getProperty("user.dir") + "\\Drivers\\IEDriverServer32.exe";
	System.setProperty("webdriver.ie.driver", path);
	DesiredCapabilities caps = DesiredCapabilities.internetExplorer();
	caps.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS,	true);
	return new InternetExplorerDriver(caps);
}
 
Example 40
Project: Spring-Security-Third-Edition   File: SeleniumTestUtilities.java   Source Code and License 5 votes vote down vote up
public static WebDriver get64IEDriver()
{
	String path = System.getProperty("user.dir") + "\\Drivers\\IEDriverServer64.exe";
	System.setProperty("webdriver.ie.driver", path);
	DesiredCapabilities caps = DesiredCapabilities.internetExplorer();
	caps.setCapability(CapabilityType.BROWSER_NAME, "IE");
	caps.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS,	true);

	return new InternetExplorerDriver(caps);
}