org.openqa.selenium.ie.InternetExplorerOptions Java Examples

The following examples show how to use org.openqa.selenium.ie.InternetExplorerOptions. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: WebDriverTypeTests.java    From vividus with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
private static DesiredCapabilities testGetIExploreWebDriver(WebDriverConfiguration configuration) throws Exception
{
    DesiredCapabilities desiredCapabilities = new DesiredCapabilities();
    InternetExplorerOptions internetExplorerOptions = new InternetExplorerOptions();
    whenNew(InternetExplorerOptions.class).withArguments(desiredCapabilities).thenReturn(internetExplorerOptions);
    whenNew(InternetExplorerOptions.class).withNoArguments().thenReturn(internetExplorerOptions);
    InternetExplorerDriver expected = mock(InternetExplorerDriver.class);
    whenNew(InternetExplorerDriver.class)
            .withParameterTypes(InternetExplorerOptions.class)
            .withArguments(internetExplorerOptions)
            .thenReturn(expected);
    WebDriver actual = WebDriverType.IEXPLORE.getWebDriver(desiredCapabilities, configuration);
    assertEquals(expected, actual);
    Map<String, Object> options = (Map<String, Object>) desiredCapabilities.getCapability(IE_OPTIONS);
    assertTrue((boolean) options.get(InternetExplorerDriver.REQUIRE_WINDOW_FOCUS));
    return desiredCapabilities;
}
 
Example #2
Source File: Browser.java    From coteafs-selenium with Apache License 2.0 6 votes vote down vote up
private static WebDriver setupIeDriver() throws MalformedURLException {
    LOG.i("Setting up Internet Explorer driver...");
    setupDriver(iedriver());
    final InternetExplorerOptions ieOptions = new InternetExplorerOptions();
    ieOptions.destructivelyEnsureCleanSession();
    ieOptions.setCapability("requireWindowFocus", true);
    ieOptions.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
    final InternetExplorerDriverService ieService = InternetExplorerDriverService.createDefaultService();
    if (!OS.isWindows()) {
        Assert.fail("IE is not supported.");
    }
    if (appSetting().isHeadlessMode()) {
        LOG.w("IE does not support headless mode. Hence, ignoring the same...");
    }
    return new InternetExplorerDriver(ieService, ieOptions);
}
 
Example #3
Source File: IECaps.java    From teasy with MIT License 6 votes vote down vote up
private InternetExplorerOptions getIEOptions() {
    InternetExplorerOptions caps = new InternetExplorerOptions();
    caps.setCapability("version", this.version);
    caps.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true);
    caps.setCapability(InternetExplorerDriver.IE_SWITCHES, "-private");
    caps.setCapability(InternetExplorerDriver.FORCE_CREATE_PROCESS, true);
    caps.setCapability(InternetExplorerDriver.IE_ENSURE_CLEAN_SESSION, true);
    caps.setCapability(CapabilityType.SUPPORTS_ALERTS, true);
    caps.setCapability("platform", Platform.WINDOWS);
    caps.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
    caps.setCapability(CapabilityType.UNEXPECTED_ALERT_BEHAVIOUR, this.alertBehaviour);

    //Found that setting this capability could increase IE tests speed. Should be checked.
    caps.setCapability(InternetExplorerDriver.REQUIRE_WINDOW_FOCUS, true);
    setLoggingPrefs(caps);
    return caps;
}
 
Example #4
Source File: InternetExplorerDriverHandler.java    From selenium-jupiter with Apache License 2.0 6 votes vote down vote up
@Override
public void resolve() {
    try {
        Optional<Object> testInstance = context.getTestInstance();
        Optional<Capabilities> capabilities = annotationsReader
                .getCapabilities(parameter, testInstance);
        InternetExplorerOptions internetExplorerOptions = (InternetExplorerOptions) getOptions(
                parameter, testInstance);
        if (capabilities.isPresent()) {
            internetExplorerOptions.merge(capabilities.get());
        }
        object = new InternetExplorerDriver(internetExplorerOptions);
    } catch (Exception e) {
        handleException(e);
    }
}
 
Example #5
Source File: IExplorerSettings.java    From aquality-selenium-java with Apache License 2.0 5 votes vote down vote up
@Override
public InternetExplorerOptions getCapabilities() {
    InternetExplorerOptions internetExplorerOptions = new InternetExplorerOptions();
    setCapabilities(internetExplorerOptions);
    internetExplorerOptions.setPageLoadStrategy(getPageLoadStrategy());
    return internetExplorerOptions;
}
 
Example #6
Source File: InternalSelenseTestBase.java    From selenium with Apache License 2.0 5 votes vote down vote up
private Capabilities createCapabilities() {
  String property = System.getProperty("selenium.browser", "ff");

  Browser browser = Browser.detect();
  switch (browser) {
    case CHROME:
      return new ChromeOptions();

    case EDGE:
      return new EdgeHtmlOptions();

    case CHROMIUMEDGE:
      return new EdgeOptions();

    case IE:
      return new InternetExplorerOptions();

    case FIREFOX:
    case MARIONETTE:
      return new FirefoxOptions();

    case OPERA:
    case OPERABLINK:
      return new OperaOptions();

    case SAFARI:
      return new SafariOptions();

    default:
      fail("Attempt to use an unsupported browser: " + property);
      // we never get here, but keep null checks happy anyway
      return new DesiredCapabilities();
  }
}
 
Example #7
Source File: W3CRemoteDriverTest.java    From selenium with Apache License 2.0 5 votes vote down vote up
@Test
public void settingBothDriverServiceAndUrlIsAnError() {
  assertThatExceptionOfType(IllegalArgumentException.class)
      .isThrownBy(() -> RemoteWebDriver.builder()
          .addAlternative(new InternetExplorerOptions())
          .url("http://example.com/cheese/peas/wd")
          .withDriverService(new FakeDriverService()));
}
 
Example #8
Source File: W3CRemoteDriverTest.java    From selenium with Apache License 2.0 5 votes vote down vote up
@Test
public void shouldUseADriverServiceIfGivenOneRegardlessOfOtherChoices() throws IOException {
  DriverService expected = new FakeDriverService();

  RemoteWebDriverBuilder builder = RemoteWebDriver.builder()
      .addAlternative(new InternetExplorerOptions())
      .withDriverService(expected);

  RemoteWebDriverBuilder.Plan plan = builder.getPlan();

  assertThat(plan.isUsingDriverService()).isTrue();
  assertThat(plan.getDriverService()).isEqualTo(expected);
}
 
Example #9
Source File: W3CRemoteDriverTest.java    From selenium with Apache License 2.0 5 votes vote down vote up
@Test
public void ifARemoteUrlIsGivenThatIsUsedForTheSession() throws MalformedURLException {
  URL expected = new URL("http://localhost:3000/woohoo/cheese");

  RemoteWebDriverBuilder builder = RemoteWebDriver.builder()
      .addAlternative(new InternetExplorerOptions())
      .url(expected.toExternalForm());

  RemoteWebDriverBuilder.Plan plan = builder.getPlan();

  assertThat(plan.isUsingDriverService()).isFalse();
  assertThat(plan.getRemoteHost()).isEqualTo(expected);
}
 
Example #10
Source File: W3CRemoteDriverTest.java    From selenium with Apache License 2.0 5 votes vote down vote up
@Test
public void shouldAllowMetaDataToBeSet() {
  Map<String, String> expected = singletonMap("cheese", "brie");
  RemoteWebDriverBuilder builder = RemoteWebDriver.builder()
      .addAlternative(new InternetExplorerOptions())
      .addMetadata("cloud:options", expected);

  Map<String, Object> payload = getPayload(builder);

  assertThat(payload.get("cloud:options")).isEqualTo(expected);
}
 
Example #11
Source File: W3CRemoteDriverTest.java    From selenium with Apache License 2.0 5 votes vote down vote up
@Test
public void ensureEachOfTheKeyOptionTypesAreSafe() {
  // Only include the options where we expect to get a w3c session
  Stream.of(
      new ChromeOptions(),
      new FirefoxOptions(),
      new InternetExplorerOptions())
      .map(options -> RemoteWebDriver.builder().addAlternative(options))
      .forEach(this::listCapabilities);
}
 
Example #12
Source File: LocalDriverFactory.java    From hsac-fitnesse-fixtures with Apache License 2.0 5 votes vote down vote up
public static InternetExplorerOptions getInternetExplorerOptions(Map<String, Object> profile) {
    InternetExplorerOptions ieOptions = new InternetExplorerOptions();
    if (profile != null) {
        for (Map.Entry<String, Object> profileEntry : profile.entrySet()) {
            ieOptions.setCapability(profileEntry.getKey(), profileEntry.getValue());
        }
    }
    return ieOptions;
}
 
Example #13
Source File: InternetExplorerImpl.java    From frameworkium-core with Apache License 2.0 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 #14
Source File: DefaultLocalDriverProviderTest.java    From webdriver-factory with Apache License 2.0 5 votes vote down vote up
@Test
@EnabledOnOs(OS.WINDOWS)
@DisabledIfEnvironmentVariable(named = "CI", matches = "true")
void canInstantiateInternetExplorerDriverWithInternetExplorerOptions() {
  driver = provider.createDriver(new InternetExplorerOptions());
  assertTrue(driver instanceof InternetExplorerDriver);
}
 
Example #15
Source File: CustomDriverProvider.java    From akita with Apache License 2.0 5 votes vote down vote up
/**
 * Задает options для запуска IE драйвера
 * options можно передавать, как системную переменную, например -Doptions=--load-extension=my-custom-extension
 *
 * @return internetExplorerOptions
 */
private InternetExplorerOptions getIEDriverOptions(DesiredCapabilities capabilities) {
    log.info("---------------IE Driver---------------------");
    InternetExplorerOptions internetExplorerOptions = !options[0].equals("") ? new InternetExplorerOptions().addCommandSwitches(options) : new InternetExplorerOptions();
    internetExplorerOptions.setCapability(CapabilityType.BROWSER_VERSION, loadSystemPropertyOrDefault(CapabilityType.BROWSER_VERSION, VERSION_LATEST));
    internetExplorerOptions.setCapability("ie.usePerProcessProxy", "true");
    internetExplorerOptions.setCapability("requireWindowFocus", "false");
    internetExplorerOptions.setCapability("ie.browserCommandLineSwitches", "-private");
    internetExplorerOptions.setCapability("ie.ensureCleanSession", "true");
    internetExplorerOptions.merge(capabilities);
    return internetExplorerOptions;
}
 
Example #16
Source File: InternetExplorerDriverHandler.java    From selenium-jupiter with Apache License 2.0 5 votes vote down vote up
@Override
public MutableCapabilities getOptions(Parameter parameter,
        Optional<Object> testInstance)
        throws IOException, IllegalAccessException {
    InternetExplorerOptions internetExplorerOptions = new InternetExplorerOptions();
    InternetExplorerOptions optionsFromAnnotatedField = annotationsReader
            .getFromAnnotatedField(testInstance, Options.class,
                    InternetExplorerOptions.class);
    if (optionsFromAnnotatedField != null) {
        internetExplorerOptions = optionsFromAnnotatedField;
    }
    return internetExplorerOptions;
}
 
Example #17
Source File: SetProxyForWebDriver.java    From neodymium-library with MIT License 5 votes vote down vote up
@Test
public void testInternetExplorer()
{
    DesiredCapabilities capabilities = createCapabilitiesWithProxy();
    InternetExplorerOptions options = new InternetExplorerOptions();
    options.merge(capabilities);

    Assert.assertTrue(options.getCapability(CapabilityType.PROXY) != null);
}
 
Example #18
Source File: DriverFactory.java    From NoraUi with GNU Affero General Public License v3.0 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));
    }
    log.info("Generating IE driver ({}) ...", pathWebdriver);

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

    final InternetExplorerOptions internetExplorerOptions = new InternetExplorerOptions();
    internetExplorerOptions.setCapability(InternetExplorerDriver.IE_ENSURE_CLEAN_SESSION, true);
    internetExplorerOptions.setCapability(InternetExplorerDriver.IGNORE_ZOOM_SETTING, true);
    internetExplorerOptions.setCapability(InternetExplorerDriver.REQUIRE_WINDOW_FOCUS, true);
    internetExplorerOptions.setCapability(InternetExplorerDriver.NATIVE_EVENTS, false);
    internetExplorerOptions.setCapability(CapabilityType.UNEXPECTED_ALERT_BEHAVIOUR, UnexpectedAlertBehaviour.ACCEPT);
    internetExplorerOptions.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true);
    internetExplorerOptions.setCapability("disable-popup-blocking", true);

    setLoggingLevel(internetExplorerOptions);

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

    return new InternetExplorerDriver(internetExplorerOptions);
}
 
Example #19
Source File: IECaps.java    From teasy with MIT License 5 votes vote down vote up
public InternetExplorerOptions get() {
    InternetExplorerOptions caps = getIEOptions();
    if (!this.customCaps.asMap().isEmpty()) {
        caps.merge(this.customCaps);
    }
    return caps;
}
 
Example #20
Source File: WebDriverCapabilities.java    From QVisual with Apache License 2.0 5 votes vote down vote up
private void setupIE() {
    InternetExplorerOptions explorerOptions = new InternetExplorerOptions();
    explorerOptions.destructivelyEnsureCleanSession();

    capabilities.setCapability("se:ieOptions", explorerOptions);
    capabilities.merge(explorerOptions);
}
 
Example #21
Source File: IeDriverCreator.java    From bobcat with Apache License 2.0 4 votes vote down vote up
@Override
public WebDriver create(Capabilities capabilities) {
  LOG.info("Starting the initialization of '{}' WebDriver instance", ID);
  LOG.debug("Initializing WebDriver with following capabilities: {}", capabilities);
  return new InternetExplorerDriver(new InternetExplorerOptions(capabilities));
}
 
Example #22
Source File: InternetExplorerFactory.java    From webtester2-core with Apache License 2.0 4 votes vote down vote up
public InternetExplorerFactory() {
    super((capabilities) -> {
        InternetExplorerOptions ieOptions = new InternetExplorerOptions().merge(capabilities);
        return new InternetExplorerDriver(ieOptions);
    });
}
 
Example #23
Source File: DefaultLocalDriverProvider.java    From webdriver-factory with Apache License 2.0 4 votes vote down vote up
public WebDriver createDriver(InternetExplorerOptions options) {
  return new InternetExplorerDriver(options);
}
 
Example #24
Source File: InternetExplorerImpl.java    From frameworkium-core with Apache License 2.0 4 votes vote down vote up
@Override
public WebDriver getWebDriver(Capabilities capabilities) {
    return new InternetExplorerDriver(new InternetExplorerOptions(capabilities));
}
 
Example #25
Source File: UiEngineConfigurator.java    From ats-framework with Apache License 2.0 4 votes vote down vote up
/**
 * @return the InternetExplorer options
 */
@PublicAtsApi
public InternetExplorerOptions getInternetExplorerDriverOptions() {

    return internetExplorerOptions;
}
 
Example #26
Source File: UiEngineConfigurator.java    From ats-framework with Apache License 2.0 4 votes vote down vote up
/**
 * Pass options which will be applied when starting a Internet Explorer browser through Selenium
 * @param options Internet Explorer options
 */
@PublicAtsApi
public void setInternetExplorerDriverOptions( InternetExplorerOptions options ) {

    internetExplorerOptions = options;
}
 
Example #27
Source File: LocallyBuiltInternetExplorerDriver.java    From selenium with Apache License 2.0 4 votes vote down vote up
public LocallyBuiltInternetExplorerDriver(Capabilities capabilities) {
  super(getService(), new InternetExplorerOptions().merge(capabilities));
}
 
Example #28
Source File: CreateDriver.java    From Selenium-Framework-Design-in-Data-Driven-Testing with MIT License 4 votes vote down vote up
/**
 * setDriver method to create driver instance
 *
 * @param browser
 * @param environment
 * @param platform
 * @param optPreferences
 * @throws Exception
 */
@SafeVarargs
public final void setDriver(String browser,
                            String platform,
                            String environment,
                            Map<String, Object>... optPreferences)
                            throws Exception {

    DesiredCapabilities caps = null;
    String getPlatform = null;
    props.load(new FileInputStream(Global_VARS.SE_PROPS));

    switch (browser) {
        case "firefox":
            caps = DesiredCapabilities.firefox();

            FirefoxOptions ffOpts = new FirefoxOptions();
            FirefoxProfile ffProfile = new FirefoxProfile();

            ffProfile.setPreference("browser.autofocus", true);
            ffProfile.setPreference("browser.tabs.remote.autostart.2", false);

            caps.setCapability(FirefoxDriver.PROFILE, ffProfile);
            caps.setCapability("marionette", true);

            // then pass them to the local WebDriver
            if ( environment.equalsIgnoreCase("local") ) {
                System.setProperty("webdriver.gecko.driver", props.getProperty("gecko.driver.windows.path"));
                webDriver.set(new FirefoxDriver(ffOpts.merge(caps)));
            }

            break;
        case "chrome":
            caps = DesiredCapabilities.chrome();

            ChromeOptions chOptions = new ChromeOptions();
            Map<String, Object> chromePrefs = new HashMap<String, Object>();

            chromePrefs.put("credentials_enable_service", false);

            chOptions.setExperimentalOption("prefs", chromePrefs);
            chOptions.addArguments("--disable-plugins", "--disable-extensions", "--disable-popup-blocking");

            caps.setCapability(ChromeOptions.CAPABILITY, chOptions);
            caps.setCapability("applicationCacheEnabled", false);

            if ( environment.equalsIgnoreCase("local") ) {
                System.setProperty("webdriver.chrome.driver", props.getProperty("chrome.driver.windows.path"));
                webDriver.set(new ChromeDriver(chOptions.merge(caps)));
            }

            break;
        case "internet explorer":
            caps = DesiredCapabilities.internetExplorer();

            InternetExplorerOptions ieOpts = new InternetExplorerOptions();

            ieOpts.requireWindowFocus();
            ieOpts.merge(caps);

            caps.setCapability("requireWindowFocus", true);

            if ( environment.equalsIgnoreCase("local") ) {
                System.setProperty("webdriver.ie.driver", props.getProperty("ie.driver.windows.path"));
                webDriver.set(new InternetExplorerDriver(ieOpts.merge(caps)));
            }

            break;
    }

    getEnv = environment;
    getPlatform = platform;
    sessionId.set(((RemoteWebDriver) webDriver.get()).getSessionId().toString());
    sessionBrowser.set(caps.getBrowserName());
    sessionVersion.set(caps.getVersion());
    sessionPlatform.set(getPlatform);

    System.out.println("\n*** TEST ENVIRONMENT = "
            + getSessionBrowser().toUpperCase()
            + "/" + getSessionPlatform().toUpperCase()
            + "/" + getEnv.toUpperCase()
            + "/Selenium Version=" + props.getProperty("selenium.revision")
            + "/Session ID=" + getSessionId() + "\n");

    getDriver().manage().timeouts().implicitlyWait(IMPLICIT_TIMEOUT, TimeUnit.SECONDS);
    getDriver().manage().window().maximize();
}