@Test public void settingBrowserSize() { // given WebDriverProperties properties = new WebDriverProperties(); properties.setProperty("browserSize", "1690x1000"); // when Capabilities convertedCapabilities = edgeCapabilitiesConverter.convert(properties); // then // expected safari options EdgeOptions expectedEdgeOptions = new EdgeOptions(); expectedEdgeOptions.setCapability(CAPABILITY_AUTOCLOSE, false); expectedEdgeOptions.setCapability(CAPABILITY_BROWSER_SIZE, "1690x1000"); assertThat(convertedCapabilities.asMap()).isEqualTo(expectedEdgeOptions.asMap()); }
@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); } }
@Test public void shouldRetrieveBrowserWithOptions() { final Map<String, String> edgeParameters = new HashMap<>(); edgeParameters.put(BROWSER_NAME, "edge"); final XmlConfig config = new XmlConfig(edgeParameters); final Browser edge = StreamEx.of(browsers) .findFirst(b -> b.name() == Browser.Name.Edge) .orElseThrow(() -> new AssertionError("Unable to retrieve Edge")); assertThat(edge.configuration(config)).isEqualTo(edge.merge(config, new EdgeOptions())); }
@Override public Capabilities convert(WebDriverProperties properties) { EdgeOptions edgeOptions = new EdgeOptions(); // general options for logging purpose edgeOptions.setCapability(CAPABILITY_AUTOCLOSE, properties.isAutoClose()); addToEdgeOptionsIfNoEmptyValue(edgeOptions, CAPABILITY_DRIVER_VERSION, properties.getDriverVersion()); addToEdgeOptionsIfNoEmptyValue(edgeOptions, CAPABILITY_BROWSER_SIZE, properties.getBrowserSize()); return edgeOptions; }
@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")); }
@Override public Capabilities configuration(final XmlConfig context) { return merge(context, new EdgeOptions()); }
protected EdgeOptions createOptions() { return new EdgeOptions(); }
private void addToEdgeOptionsIfNoEmptyValue(EdgeOptions edgeOptions, String key, String value) { if (isNotEmpty(value)) { edgeOptions.setCapability(key, value); } }
@Override public WebDriver createDriver(Capabilities capabilities) { String driverVersion = (String) capabilities.getCapability(CAPABILITY_DRIVER_VERSION); EdgeDriverManager.getInstance().version(driverVersion).setup(); return new EdgeDriver((EdgeOptions) capabilities); }
/** * Creates a new EdgeDriver instance with the specified options. * * @param options The options to use. * @see #EdgeDriver(EdgeDriverService, EdgeOptions) */ public EdgeDriver(EdgeOptions options) { super(new org.openqa.selenium.edge.EdgeDriver(options)); }
/** * Creates a new EdgeDriver instance with the specified options. The {@code service} will be * started along with the driver, and shutdown upon calling {@link #quit()}. * * @param service The service to use. * @param options The options to use. */ public EdgeDriver(EdgeDriverService service, EdgeOptions options) { super(new org.openqa.selenium.edge.EdgeDriver(service, options)); }