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);
}
 
Example 41
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 42
Project: Actitime-Framework   File: DriverFactory.java   Source Code and License 5 votes vote down vote up
protected void ieDriver() {
	DesiredCapabilities capabilities = DesiredCapabilities.internetExplorer();
	capabilities.setCapability(InternetExplorerDriver.NATIVE_EVENTS, false);
	capabilities.setCapability(InternetExplorerDriver.ENABLE_PERSISTENT_HOVERING, false);
	capabilities.setCapability(InternetExplorerDriver.REQUIRE_WINDOW_FOCUS, false);
	capabilities.setCapability(InternetExplorerDriver.IE_ENSURE_CLEAN_SESSION, true);
	capabilities.setCapability(InternetExplorerDriver.IGNORE_ZOOM_SETTING, true);
	capabilities.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true);
	System.setProperty("webdriver.ie.driver","./src/main/resources/iedriver/IEDriverServer.exe");
	driver = new InternetExplorerDriver(capabilities);
	driver.manage().window().maximize();
}
 
Example 43
Project: PatatiumWebUi   File: TestBaseCase.java   Source Code and License 5 votes vote down vote up
/**
 * 用枚举类型列出浏览器列表,用于设置浏览器类型的函数参数
 * @author zheng
 *
 */
private WebDriver setDriver(String browsername)
{
	switch (browsername)
	{

		case "FirefoxDriver" :
			System.setProperty("webdriver.firefox.bin", "C:/Program Files (x86)/Mozilla Firefox/firefox.exe");
			FirefoxProfile firefoxProfile=new FirefoxProfile();
			//设置默认下载路径
			firefoxProfile.setPreference("browser.download.folderList", 2);
			firefoxProfile.setPreference("browser.download.dir", "D:\\自动化测试下载文件");
			//加载firebug插件
			firefoxProfile.setPreference("extensions.firebug.currentVersion", "2.0.13");
			firefoxProfile.setPreference("extensions.firebug.allPagesActivation", "none");
			//加载firepath插件
			firefoxProfile.setPreference("extensions.firepath.currentVersion", "0.9.7.1.1");
			firefoxProfile.setPreference("extensions.firepath.allPagesActivation", "on");
			this.driver=new FirefoxDriver(firefoxProfile);
			break;
		case "ChormeDriver":
			System.setProperty("webdriver.chrome.driver", "resource\\chromedriver.exe");
			this.driver=new ChromeDriver();
			break;
		case "InternetExplorerDriver":
			System.setProperty("webdriver.ie.driver", "resource\\IEDriverServer_Win32_2.48.0\\IEDriverServer.exe");
			DesiredCapabilities dc = DesiredCapabilities.internetExplorer();
			dc.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true);
			dc.setCapability("ignoreProtectedModeSettings", true);
			this.driver=new InternetExplorerDriver(dc);
			break;
		case "HtmlUnitDriver":
			this.driver=new HtmlUnitDriver();
			break;
		default:
			this.driver=new FirefoxDriver();
			break;
	}
	return driver;
}
 
Example 44
Project: SeleniumCucumber   File: IExploreBrowser.java   Source Code and License 5 votes vote down vote up
public Capabilities getIExplorerCapabilities() {
	DesiredCapabilities cap = DesiredCapabilities.internetExplorer();
	cap.setCapability(InternetExplorerDriver.ELEMENT_SCROLL_BEHAVIOR,
			ElementScrollBehavior.BOTTOM);
	cap.setCapability(InternetExplorerDriver.IE_ENSURE_CLEAN_SESSION, true);
	cap.setCapability(
			InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS,
			true);
	cap.setCapability(InternetExplorerDriver.IGNORE_ZOOM_SETTING, true);
	cap.setJavascriptEnabled(true);
	return cap;
}
 
Example 45
Project: domui   File: WebDriverFactory.java   Source Code and License 5 votes vote down vote up
@NotNull private static WebDriver allocateIEDriver(BrowserModel browser, Locale lang) {
	InternetExplorerDriver wd = new InternetExplorerDriver(getIECapabilities(browser, lang));
	String browserName = wd.getCapabilities().getBrowserName();
	String version = wd.getCapabilities().getVersion();
	System.out.println("wd: allocated " + browserName + " " + version);
	return wd;
}
 
Example 46
Project: KeywordDrivenAutoTest   File: InternetExplorer.java   Source Code and License 5 votes vote down vote up
/**
 * 本地初始化IE浏览器driver
 */
public InternetExplorer() {
    System.setProperty("webdriver.ie.driver", System.getProperty("user.dir") + Constants.IE_PATH);
    InternetExplorerDriverService service = (InternetExplorerDriverService) ((InternetExplorerDriverService.Builder) new InternetExplorerDriverService.Builder()
            .usingAnyFreePort()).build();
    DesiredCapabilities capabilities = DesiredCapabilities.internetExplorer();
    capabilities.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true);// 关闭保护模式,IE默认为开启模式
    capabilities.setCapability("unexpectedAlertBehaviour", "accept");
    this.driver = new InternetExplorerDriver(service, capabilities);
}
 
Example 47
Project: webdrivermanager   File: IExplorerVersionTest.java   Source Code and License 5 votes vote down vote up
@Before
public void setup() {
    browserManager = WebDriverManager
            .getInstance(InternetExplorerDriver.class)
            .operativeSystem(WIN);
    specificVersions = new String[] { "2.39", "2.47" };
}
 
Example 48
Project: webUIAuto   File: WebDriverFactory.java   Source Code and License 5 votes vote down vote up
/**
 * Set the driver as Internet Explorer.
 * 
 * @return WebDriver
 */
public WebDriver setInternetExplorerDriver() {
	System.setProperty("webdriver.ie.driver",
			getClass().getResource("/driver/IEDriverServer.exe").getPath());
	DesiredCapabilities ieCapability = DesiredCapabilities
			.internetExplorer();
	ieCapability
			.setCapability(
					InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS,
					true);
	driver = new InternetExplorerDriver(ieCapability);
	return driver;
}
 
Example 49
Project: java_pft   File: ApplicationManager.java   Source Code and License 5 votes vote down vote up
public void init() throws IOException {
  String target = System.getProperty("target", "local");
  properties.load(new FileReader(new File(String.format("src/test/resources/%s.properties", target))));

  dbHelper = new DbHelper();

  if ("".equals(properties.getProperty("selenium.server"))) {
    if (browser.equals(BrowserType.FIREFOX)) {
      wd = new FirefoxDriver();
    } else if (browser.equals(BrowserType.CHROME)) {
      wd = new ChromeDriver();
    } else if (browser.equals(BrowserType.IE)) {
      wd = new InternetExplorerDriver();
    }
  } else {
    DesiredCapabilities capabilities = new DesiredCapabilities();
    capabilities.setBrowserName(browser);
    capabilities.setPlatform(Platform.fromString(System.getProperty("platform", "win7")));
    wd = new RemoteWebDriver(new URL(properties.getProperty("selenium.server")), capabilities);
  }
  wd.manage().timeouts().implicitlyWait(0, TimeUnit.SECONDS);
  wd.get(properties.getProperty("web.baseUrl"));
  groupHelper = new GroupHelper(wd);
  contactHelper = new ContactHelper(wd);
  navigationHelper = new NavigationHelper(wd);
  sessionHelper = new SessionHelper(wd);
  sessionHelper.login(properties.getProperty("web.adminLogin"), properties.getProperty("web.adminPassword"));
}
 
Example 50
Project: JDI   File: SeleniumDriverFactory.java   Source Code and License 5 votes vote down vote up
private Supplier<WebDriver> getDefaultDriver(DriverTypes driverType) {
    switch (driverType) {
        case CHROME: return () -> new ChromeDriver(defaultChromeOptions());
        case FIREFOX: return () -> new FirefoxDriver(defaultFirefoxOptions());
        case IE: return () -> new InternetExplorerDriver(defaultIEOptions());
    }
    throw exception("Unknown driver: " + driverType);
}
 
Example 51
Project: wordpressSelenium   File: Framework.java   Source Code and License 5 votes vote down vote up
private static WebDriver getBrowser(String b) {
	if(b.equals("ie"))
		return new InternetExplorerDriver();
	else if(b.equals("ch"))
		return new ChromeDriver();
	return new FirefoxDriver();
	
}
 
Example 52
Project: wordpressSelenium   File: ScenarioSetup.java   Source Code and License 5 votes vote down vote up
@BeforeMethod
public void setup(){
	
	if(GlobalConstants.browser.equalsIgnoreCase("ie"))
		 GlobalConstants.driver =  new InternetExplorerDriver();
	else if(GlobalConstants.browser.equals("ch"))
		GlobalConstants.driver =new ChromeDriver();
	else
		GlobalConstants.driver=new FirefoxDriver();
	GlobalConstants.driver.manage().window().maximize();
}
 
Example 53
Project: FuncaoWeb   File: DriverInternetExplorer.java   Source Code and License 5 votes vote down vote up
private WebDriver getIeConfigurado(String proxy) {

		org.openqa.selenium.Proxy proxyy = new org.openqa.selenium.Proxy();
		proxyy.setHttpProxy(proxy);
		proxyy.setFtpProxy(proxy);
		proxyy.setSslProxy(proxy);
		proxyy.setAutodetect(false);

		DesiredCapabilities capabilities = DesiredCapabilities
				.internetExplorer();
		capabilities
				.setCapability(
						InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS,
						false);
		capabilities.setCapability(CapabilityType.PROXY, proxyy);
		capabilities.setBrowserName("ie");

		ieService = new InternetExplorerDriverService.Builder()
				.usingDriverExecutable(new File(InterNavegador.PATH_IEX))
				.usingAnyFreePort().build();
		try {
			ieService.start();
		} catch (IOException e) {
			System.out.println(e);
		}
		return new RemoteWebDriver(ieService.getUrl(), capabilities);

		// return new InternetExplorerDriver(capabilities);

	}
 
Example 54
Project: UIFramework   File: DriverFactory.java   Source Code and License 5 votes vote down vote up
@Override
protected WebDriver initialValue() {
	
	String browserType = PropertiesRepository.getString("global.browser.name");
	DesiredCapabilities dc = CapabilityGenerator.getCapabilities(browserType);
	logger.info("Desired Capabilities : " + dc);
	
	if (PropertiesRepository.getBoolean("global.grid.mode")) {
		try {
			URL hubURL = new URL(PropertiesRepository.getString("global.grid.hub"));					
			logger.info("Hub URL : " + hubURL);					
			return new RemoteWebDriver(hubURL, dc);
		} catch (MalformedURLException e) {
			logger.error(ExceptionConstants.PROPERTIES_EXCEPTION, e);
			return null;
		}
	} else {
		switch (browserType) {
			case GlobalProperties.FIREFOX:
				return new FirefoxDriver(dc);
			case GlobalProperties.IE:
				return new InternetExplorerDriver(dc);
			case GlobalProperties.CHROME:
				return new ChromeDriver(dc);
			default:
				return new FirefoxDriver(dc);
		}
	}
}
 
Example 55
Project: frameworkium-core   File: InternetExplorerImpl.java   Source Code and License 5 votes vote down vote up
@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;
}
 
Example 56
Project: webtester-core   File: InternetExplorerFactory.java   Source Code and License 5 votes vote down vote up
public InternetExplorerFactory() {
    super(new Function<DesiredCapabilities, WebDriver>() {
        @Override
        public WebDriver apply(DesiredCapabilities capabilities) {
            return new InternetExplorerDriver(capabilities);
        }
    });
}
 
Example 57
Project: kspl-selenium-helper   File: xRemoteWebDriver.java   Source Code and License 5 votes vote down vote up
public static WebDriver getInstance(WebDriverConfig config, Log log) throws MalformedURLException, FileNotFoundException{
 if(!config.isIntenal()){
  DesiredCapabilities cap = config.getDesiredCapabilities();
  return 
		  new xRemoteWebDriver(new URL(config.getRemoteURL()), cap, log);
 }
 else{
  File chromeDriver = new File("drivers\\chromedriver.exe");
  File IEDriver = new File("drivers\\IEDriverServer.exe");
if(config.getDesiredCapabilities().getBrowserName().equals("firefox"))
	return new FirefoxDriver();
if(config.getDesiredCapabilities().getBrowserName().equals("chrome")){
	if(!chromeDriver.exists()) throw new FileNotFoundException("chromedriver.exe not found under 'drivers' folder");
	System.setProperty("webdriver.chrome.driver", chromeDriver.getAbsolutePath());
	if(config.getChromeOptions() != null)
		return new ChromeDriver(config.getChromeOptions());
	return new ChromeDriver();
}
if(config.getDesiredCapabilities().getBrowserName().equals("internet explorer")){
	if(!IEDriver.exists()) throw new FileNotFoundException("IEDriverServer.exe is not found under 'drivers' folder");
	System.setProperty("webdriver.ie.driver", IEDriver.getAbsolutePath());
	return new InternetExplorerDriver();
}
 }
 return new FirefoxDriver();
 
}
 
Example 58
Project: selenium-spoon-plugin   File: DriverFactory.java   Source Code and License 5 votes vote down vote up
/**
 * 获取internet driver
 */
public static WebDriver getInternetDriver()
{
    WebDriver driver = new InternetExplorerDriver();
    driver.manage().window().setPosition(new Point(0, 0));
    driver.manage().window().setSize(new Dimension((int)width, (int)height));
    return driver;
}
 
Example 59
Project: easycukes   File: WebDriverFactory.java   Source Code and License 5 votes vote down vote up
/**
 * Creates a new IE driver instance
 *
 * @return a InternetExplorerDriver instance
 */
private static WebDriver newLocalIEDriver() {
    if (configuration.getValues().selenium != null
            && configuration.getValues().selenium.getIe_driver_path() != null) {
        final File file_ie = new File(configuration.getValues().selenium.getIe_driver_path());
        System.setProperty("webdriver.ie.driver", file_ie.getAbsolutePath());
    }
    return new InternetExplorerDriver(ieCapabilities());
}
 
Example 60
Project: hsac-fitnesse-fixtures   File: SeleniumHelper.java   Source Code and License 5 votes vote down vote up
/**
 * @return true when current driver is connected to either a local or remote Internet Explorer.
 */
public boolean connectedToInternetExplorer() {
    boolean result = false;
    WebDriver driver = driver();
    if (driver instanceof InternetExplorerDriver) {
        result = true;
    } else if (driver instanceof RemoteWebDriver) {
        result = checkRemoteBrowserName(driver, "internet explorer");
    }
    return result;
}