@Test public void settingBrowserSize() { // given WebDriverProperties properties = new WebDriverProperties(); properties.setProperty("browserSize", "1690x1000"); // when Capabilities convertedCapabilities = operaCapabilitiesConverter.convert(properties); // then // expected safari options OperaOptions expectedOperaOptions = new OperaOptions(); expectedOperaOptions.setCapability(CAPABILITY_AUTOCLOSE, false); expectedOperaOptions.setCapability(CAPABILITY_BROWSER_SIZE, "1690x1000"); assertThat(convertedCapabilities.asMap()).isEqualTo(expectedOperaOptions.asMap()); }
@Override public void resolve() { try { Optional<Object> testInstance = context.getTestInstance(); Optional<Capabilities> capabilities = annotationsReader .getCapabilities(parameter, testInstance); OperaOptions operaOptions = (OperaOptions) getOptions(parameter, testInstance); if (capabilities.isPresent()) { operaOptions.merge(capabilities.get()); } object = new OperaDriver(operaOptions); } catch (Exception e) { handleException(e); } }
@Before public void setupTest() { File operaBinary = IS_OS_WINDOWS ? new File("C:\\Program Files\\Opera\\launcher.exe") : new File("/usr/bin/opera"); assumeTrue(operaBinary.exists()); OperaOptions options = new OperaOptions(); options.setBinary(operaBinary); driver = new OperaDriver(options); }
@Override public Capabilities convert(WebDriverProperties properties) { OperaOptions operaOptions = new OperaOptions(); // general options for logging purpose operaOptions.setCapability(CAPABILITY_AUTOCLOSE, properties.isAutoClose()); addToOperaOptionsIfNoEmptyValue(operaOptions, CAPABILITY_DRIVER_VERSION, properties.getDriverVersion()); addToOperaOptionsIfNoEmptyValue(operaOptions, CAPABILITY_BROWSER_SIZE, properties.getBrowserSize()); return operaOptions; }
private DesiredCapabilities getCapabilities(BrowserType browser, boolean enableVnc) throws IllegalAccessException, IOException { DesiredCapabilities capabilities = browser.getCapabilities(); if (enableVnc) { capabilities.setCapability("enableVNC", true); capabilities.setCapability("screenResolution", getString("sel.jup.vnc.screen.resolution")); } if (recording) { capabilities.setCapability("enableVideo", true); capabilities.setCapability("videoScreenSize", getString("sel.jup.recording.video.screen.size")); capabilities.setCapability("videoFrameRate", getInt("sel.jup.recording.video.frame.rate")); } Optional<Capabilities> optionalCapabilities = annotationsReader .getCapabilities(parameter, testInstance); MutableCapabilities options = browser.getDriverHandler() .getOptions(parameter, testInstance); // Due to bug in operablink the binary path must be set if (browser == OPERA) { ((OperaOptions) options).setBinary("/usr/bin/opera"); } if (optionalCapabilities.isPresent()) { options.merge(optionalCapabilities.get()); } capabilities.setCapability(browser.getOptionsKey(), options); log.trace("Using capabilities for Docker browser {}", capabilities); return capabilities; }
@Test void testOperaOptions() throws Exception { Parameter parameter = OperaWithOptionsJupiterTest.class .getMethod("operaTest", OperaDriver.class).getParameters()[0]; OperaOptions operaOptions = (OperaOptions) annotationsReader .getOptions(parameter, empty()); assertThat(operaOptions.asMap().get("operaOptions").toString(), containsString("binary")); }
protected void setupOperaDriver() { DesiredCapabilities capabilities = DesiredCapabilities.operaBlink(); OperaOptions options = new OperaOptions(); options.setBinary(new File("/usr/bin/opera")); capabilities.setCapability(OperaOptions.CAPABILITY, options); setDriver(new OperaDriver(capabilities)); getDriver().manage().window().setSize( new Dimension(1366, 768)); }
private void addToOperaOptionsIfNoEmptyValue(OperaOptions operaOptions, String key, String value) { if (isNotEmpty(value)) { operaOptions.setCapability(key, value); } }
@Override public WebDriver createDriver(Capabilities capabilities) { String driverVersion = (String) capabilities.getCapability(CAPABILITY_DRIVER_VERSION); OperaDriverManager.getInstance().version(driverVersion).setup(); return new OperaDriver((OperaOptions) capabilities); }
/** * Creates a new OperaDriver instance with the specified options. * * @param options The options to use. * @see #OperaDriver(OperaDriverService, OperaOptions) */ public OperaDriver(OperaOptions options) { super(new org.openqa.selenium.opera.OperaDriver(options)); }
/** * Creates a new OperaDriver 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 OperaDriver(OperaDriverService service, OperaOptions options) { super(new org.openqa.selenium.opera.OperaDriver(service, options)); }