org.openqa.selenium.edge.EdgeOptions Java Examples

The following examples show how to use org.openqa.selenium.edge.EdgeOptions. 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: TestEdgeDriver.java    From selenium with Apache License 2.0 6 votes vote down vote up
private static Capabilities edgeWithCustomCapabilities(Capabilities originalCapabilities) {
  EdgeOptions options = new EdgeOptions();

  options.addArguments("disable-extensions", "disable-infobars", "disable-breakpad");
  Map<String, Object> prefs = new HashMap<>();
  prefs.put("exit_type", "None");
  prefs.put("exited_cleanly", true);
  options.setExperimentalOption("prefs", prefs);
  String edgePath = System.getProperty("webdriver.edge.binary");
  if (edgePath != null) {
    options.setBinary(new File(edgePath));
  }

  if (originalCapabilities != null) {
    options.merge(originalCapabilities);
  }

  return options;
}
 
Example #2
Source File: EdgeDriverHandler.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);
        EdgeOptions edgeOptions = (EdgeOptions) getOptions(parameter,
                testInstance);
        if (capabilities.isPresent()) {
            edgeOptions.merge(capabilities.get());
        }
        object = new EdgeDriver(edgeOptions);
    } catch (Exception e) {
        handleException(e);
    }
}
 
Example #3
Source File: EdgeAnnotationReaderTest.java    From selenium-jupiter with Apache License 2.0 5 votes vote down vote up
@Test
void testAnnotatedEdgeOptionsIsSelectedOverOtherAnnotatedOptions()
        throws Exception {
    Optional<Object> testInstance = Optional
            .of(new ClassWithMultipleOptions());
    EdgeOptions edgeOptions = (EdgeOptions) annotationsReader
            .getOptions(null, testInstance);
    assertThat(edgeOptions, notNullValue());
}
 
Example #4
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 #5
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 canInstantiateEdgeDriverWithEdgeOptions() {
  driver = provider.createDriver(new EdgeOptions());
  assertTrue(driver instanceof EdgeDriver);
}
 
Example #6
Source File: EdgeDevTest.java    From webdrivermanager-examples with Apache License 2.0 5 votes vote down vote up
@Before
public void setupTest() {
    ChromeOptions chromeOptions = new ChromeOptions();
    chromeOptions.setBinary(
            "C:\\Program Files (x86)\\Microsoft\\Edge Dev\\Application\\msedge.exe");
    EdgeOptions edgeOptions = new EdgeOptions().merge(chromeOptions);
    driver = new EdgeDriver(edgeOptions);
}
 
Example #7
Source File: CustomDriverProvider.java    From akita with Apache License 2.0 5 votes vote down vote up
/**
 * Задает options для запуска Edge драйвера
 * options можно передавать, как системную переменную, например -Doptions=--load-extension=my-custom-extension
 *
 * @return edgeOptions
 */
private EdgeOptions getEdgeDriverOptions(DesiredCapabilities capabilities) {
    log.info("---------------Edge Driver---------------------");
    EdgeOptions edgeOptions = new EdgeOptions();
    edgeOptions.setCapability(CapabilityType.BROWSER_VERSION, loadSystemPropertyOrDefault(CapabilityType.BROWSER_VERSION, VERSION_LATEST));
    edgeOptions.merge(capabilities);
    return edgeOptions;
}
 
Example #8
Source File: WebDriverTypeTests.java    From vividus with Apache License 2.0 5 votes vote down vote up
@Test
@PrepareForTest(fullyQualifiedNames = "org.vividus.selenium.WebDriverType$5")
public void testGetEdgeWebDriver() throws Exception
{
    DesiredCapabilities desiredCapabilities = new DesiredCapabilities();
    EdgeOptions edgeOptions = new EdgeOptions();
    edgeOptions.merge(desiredCapabilities);
    edgeOptions.setCapability("ms:inPrivate", true);
    EdgeDriver expected = mock(EdgeDriver.class);
    whenNew(EdgeDriver.class).withParameterTypes(EdgeOptions.class).withArguments(edgeOptions).thenReturn(expected);
    WebDriver actual = WebDriverType.EDGE.getWebDriver(desiredCapabilities, new WebDriverConfiguration());
    assertEquals(expected, actual);
}
 
Example #9
Source File: EdgeAnnotationReaderTest.java    From selenium-jupiter with Apache License 2.0 5 votes vote down vote up
@ParameterizedTest
@MethodSource("testClassProvider")
void testEdgeOptions(Class<?> testClass) throws Exception {
    Parameter parameter = testClass.getMethod("edgeTest", EdgeDriver.class)
            .getParameters()[0];
    Optional<Object> testInstance = Optional.of(testClass.newInstance());
    EdgeOptions edgeOptions = (EdgeOptions) annotationsReader
            .getOptions(parameter, testInstance);
    assertThat(edgeOptions.getCapability("pageLoadStrategy"),
            equalTo("eager"));
}
 
Example #10
Source File: EdgeDriverHandler.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 {
    EdgeOptions edgeOptions = new EdgeOptions();
    EdgeOptions optionsFromAnnotatedField = annotationsReader
            .getFromAnnotatedField(testInstance, Options.class,
                    EdgeOptions.class);
    if (optionsFromAnnotatedField != null) {
        edgeOptions = optionsFromAnnotatedField;
    }
    return edgeOptions;
}
 
Example #11
Source File: WebDriverFactory.java    From KITE with Apache License 2.0 5 votes vote down vote up
/**
   * Build capabilities for client web driver
   *
   * @param client the Client object
   * @return capabilities appium driver
   */
  private static MutableCapabilities buildBrowserCapabilities(Client client) {
    MutableCapabilities capabilities = new MutableCapabilities();
    BrowserSpecs specs = client.getBrowserSpecs();
    if (specs.getVersion() != null) {
      capabilities.setCapability(CapabilityType.VERSION, specs.getVersion());
    }
    if (specs.getPlatform() != null) {
      capabilities.setCapability(CapabilityType.PLATFORM_NAME, specs.getPlatform());
    }

//    if (client.getCapability().getGateway().toString() != null && !"none".equalsIgnoreCase(client.getCapability().getGateway().toString())) {
//      capabilities.setCapability("gateway", client.getCapability().getGateway().toString());
//    }

    // Only consider next code block if this is a client.
    switch (specs.getBrowserName()) {
      case "chrome":
        capabilities.setCapability(ChromeOptions.CAPABILITY, setCommonChromeOptions(client.getCapability(), specs));
        break;
      case "firefox":
        capabilities.merge(setCommonFirefoxOptions(client.getCapability(), specs));
        break;
      case "MicrosoftEdge":
        EdgeOptions MicrosoftEdgeOptions = new EdgeOptions();
        capabilities.setCapability("edgeOptions", MicrosoftEdgeOptions);
        capabilities.setCapability("avoidProxy", true);
        break;
      case "safari":
        SafariOptions options = new SafariOptions();
        options.setUseTechnologyPreview(client.getCapability().isTechnologyPreview());
        capabilities.setCapability(SafariOptions.CAPABILITY, options);
        break;
      default:
        capabilities.setCapability(CapabilityType.BROWSER_NAME, specs.getBrowserName());
        break;
    }
    // Add log preference to webdriver
    // TODO put log preference into config file
    LoggingPreferences logPrefs = new LoggingPreferences();
    logPrefs.enable(LogType.BROWSER, Level.ALL);
    capabilities.setCapability(CapabilityType.LOGGING_PREFS, logPrefs);
//    capabilities.setCapability("goog:loggingPrefs", logPrefs);
    // Capabilities for mobile client/app
    if (specs.getPlatform().toString().equalsIgnoreCase("android")
      ||specs.getPlatform().toString().equalsIgnoreCase("ios")) {
      // deviceName:
      // On iOS, this should be one of the valid devices returned by instruments with instruments -s devices.
      // On Android this capability is currently ignored, though it remains required.
      capabilities.setCapability("deviceName", specs.getDeviceName());
      capabilities.setCapability("platformName", specs.getPlatform());
      capabilities.setCapability("platformVersion", specs.getPlatformVersion());
      if (specs.getPlatform().name().equalsIgnoreCase("ios")) {
        capabilities.setCapability("automationName", "XCUITest");
        capabilities.setCapability("autoAcceptAlerts", true);
      } else {
        capabilities.setCapability("autoGrantPermissions", true);
        capabilities.setCapability(MobileCapabilityType.NEW_COMMAND_TIMEOUT, 300);
      }
      capabilities.setCapability("noReset", true);
    }
    return capabilities;
  }
 
Example #12
Source File: WebDriverTypeTests.java    From vividus with Apache License 2.0 5 votes vote down vote up
@Test
@PrepareForTest(fullyQualifiedNames = "org.vividus.selenium.WebDriverType$7")
public void testGetEdgeChromiumWebDriver() throws Exception
{
    DesiredCapabilities desiredCapabilities = new DesiredCapabilities();
    EdgeOptions edgeOptions = new EdgeOptions();
    edgeOptions.merge(desiredCapabilities);
    EdgeDriver expected = mock(EdgeDriver.class);
    whenNew(EdgeDriver.class).withParameterTypes(EdgeOptions.class).withArguments(edgeOptions).thenReturn(expected);
    WebDriver actual = WebDriverType.EDGE_CHROMIUM.getWebDriver(desiredCapabilities, new WebDriverConfiguration());
    assertEquals(expected, actual);
}
 
Example #13
Source File: EdgeCaps.java    From teasy with MIT License 5 votes vote down vote up
private EdgeOptions getEdgeOptions() {
    EdgeOptions options = new EdgeOptions();
    options.setCapability("platform", Platform.WINDOWS);
    options.setCapability(CapabilityType.UNEXPECTED_ALERT_BEHAVIOUR, this.alertBehaviour);
    setLoggingPrefs(options);
    return options;
}
 
Example #14
Source File: EdgeCaps.java    From teasy with MIT License 5 votes vote down vote up
public EdgeOptions get() {
    EdgeOptions caps = getEdgeOptions();
    if (!this.customCaps.asMap().isEmpty()) {
        caps.merge(this.customCaps);
    }
    return caps;
}
 
Example #15
Source File: EdgeSettings.java    From aquality-selenium-java with Apache License 2.0 5 votes vote down vote up
@Override
public EdgeOptions getCapabilities() {
    EdgeOptions edgeOptions = new EdgeOptions();
    setCapabilities(edgeOptions);
    edgeOptions.setPageLoadStrategy(getPageLoadStrategy().toString());
    return edgeOptions;
}
 
Example #16
Source File: Free_ssCrawlerServiceImpl.java    From ShadowSocks-Share with Apache License 2.0 5 votes vote down vote up
@Override
public WebDriver getDriver() {
	System.setProperty("webdriver.edge.driver", driverPath);
	// System.setProperty("webdriver.ie.driver.loglevel", "DEBUG");

	org.openqa.selenium.edge.EdgeDriverService service = org.openqa.selenium.edge.EdgeDriverService.createDefaultService();

	EdgeOptions options = new EdgeOptions();
	return new EdgeDriver(service, options);
}
 
Example #17
Source File: Browser.java    From coteafs-selenium with Apache License 2.0 4 votes vote down vote up
private static WebDriver setupEdgeDriver() throws MalformedURLException {
    LOG.i("Setting up Edge driver...");
    setupDriver(edgedriver());
    final EdgeOptions options = new EdgeOptions();
    return new EdgeDriver(options);
}
 
Example #18
Source File: EdgeHtmlDriverServiceTest.java    From selenium with Apache License 2.0 4 votes vote down vote up
@Test
public void testScoring() {
  EdgeHtmlDriverService.Builder builder = new EdgeHtmlDriverService.Builder();
  assertThat(builder.score(new EdgeHtmlOptions())).isGreaterThan(0);
  assertThat(builder.score(new EdgeOptions())).isEqualTo(0);
}
 
Example #19
Source File: EdgeDriver.java    From selenium with Apache License 2.0 4 votes vote down vote up
@Deprecated
public EdgeDriver(Capabilities capabilities) {
  this(new EdgeDriverService.Builder().build(), new EdgeOptions().merge(capabilities));
}
 
Example #20
Source File: EdgeDriver.java    From selenium with Apache License 2.0 4 votes vote down vote up
public EdgeDriver(EdgeDriverService service, EdgeOptions options) {
  super(new ChromiumDriverCommandExecutor("ms", service), Require.nonNull("Driver options", options), EdgeOptions.CAPABILITY);
}
 
Example #21
Source File: EdgeDriver.java    From selenium with Apache License 2.0 4 votes vote down vote up
public EdgeDriver(EdgeDriverService service) {
  this(service, new EdgeOptions());
}
 
Example #22
Source File: EdgeDriver.java    From selenium with Apache License 2.0 4 votes vote down vote up
public EdgeDriver(EdgeOptions options) {
  this(new EdgeDriverService.Builder().build(), options);
}
 
Example #23
Source File: EdgeImpl.java    From frameworkium-core with Apache License 2.0 4 votes vote down vote up
@Override
public EdgeOptions getCapabilities() {
    return new EdgeOptions();
}
 
Example #24
Source File: UiEngineConfigurator.java    From ats-framework with Apache License 2.0 4 votes vote down vote up
/**
 * @return the Edge options
 */
public EdgeOptions getEdgeDriverOptions() {

    return edgeOptions;
}
 
Example #25
Source File: DefaultLocalDriverProvider.java    From webdriver-factory with Apache License 2.0 4 votes vote down vote up
public WebDriver createDriver(EdgeOptions options) {
  return new EdgeDriver(options);
}
 
Example #26
Source File: EdgeFactory.java    From webtester2-core with Apache License 2.0 4 votes vote down vote up
public EdgeFactory() {
    super((capabilities) -> {
        EdgeOptions edgeOptions = new EdgeOptions().merge(capabilities);
        return new EdgeDriver(edgeOptions);
    });
}
 
Example #27
Source File: EdgeDriverCreator.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 EdgeDriver(new EdgeOptions().merge(capabilities));
}
 
Example #28
Source File: WebDriverCapabilities.java    From QVisual with Apache License 2.0 4 votes vote down vote up
private void setupEdge() {
    EdgeOptions edgeOptions = new EdgeOptions();

    capabilities.merge(edgeOptions);
}
 
Example #29
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 Edge browser through Selenium
 * @param options Internet Explorer options
 */
@PublicAtsApi
public void setEdgeDriverOptions( EdgeOptions options ) {

    edgeOptions = options;
}
 
Example #30
Source File: SearchTestWithEdge.java    From Selenium-WebDriver-3-Practical-Guide-Second-Edition with MIT License 3 votes vote down vote up
@BeforeMethod
public void setup() {

    System.setProperty("webdriver.edge.driver",
            "./src/test/resources/drivers/MicrosoftWebDriver.exe");

    EdgeOptions options = new EdgeOptions();
    options.setPageLoadStrategy("eager");

    driver = new EdgeDriver(options);

    driver.get("http://demo-store.seleniumacademy.com/");
}