org.openqa.selenium.opera.OperaOptions Java Examples

The following examples show how to use org.openqa.selenium.opera.OperaOptions. 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: OperaDriverHandler.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);
        OperaOptions operaOptions = (OperaOptions) getOptions(parameter,
                testInstance);
        if (capabilities.isPresent()) {
            operaOptions.merge(capabilities.get());
        }

        object = new OperaDriver(operaOptions);
    } catch (Exception e) {
        handleException(e);
    }
}
 
Example #2
Source File: WebDriverTypeTests.java    From vividus with Apache License 2.0 5 votes vote down vote up
private static void testGetOperaWebDriver(WebDriverConfiguration configuration, OperaOptions operaOptions)
        throws Exception
{
    DesiredCapabilities desiredCapabilities = new DesiredCapabilities();
    OperaDriver expected = mock(OperaDriver.class);
    whenNew(OperaDriver.class).withParameterTypes(OperaOptions.class).withArguments(operaOptions)
            .thenReturn(expected);
    WebDriver actual = WebDriverType.OPERA.getWebDriver(desiredCapabilities, configuration);
    assertEquals(expected, actual);
}
 
Example #3
Source File: WebDriverTypeTests.java    From vividus with Apache License 2.0 5 votes vote down vote up
@Test
@PrepareForTest(fullyQualifiedNames = "org.vividus.selenium.WebDriverType$6")
public void testGetOperaWebDriverWithAdditionalOptions() throws Exception
{
    Map<String, String> experimentalOptionValue = singletonMap(OPTION_KEY, OPTION_VALUE);
    WebDriverConfiguration configuration = new WebDriverConfiguration();
    configuration.setBinaryPath(Optional.of(PATH));
    configuration.setCommandLineArguments(new String[] { ARGUMENT });
    configuration.setExperimentalOptions(singletonMap(MOBILE_EMULATION, experimentalOptionValue));
    OperaOptions operaOptions = new OperaOptions();
    operaOptions.setBinary(PATH);
    operaOptions.addArguments(ARGUMENT);
    operaOptions.setExperimentalOption(MOBILE_EMULATION, experimentalOptionValue);
    testGetOperaWebDriver(configuration, operaOptions);
}
 
Example #4
Source File: CreateRepositoryInGitHubStepDefinition.java    From base_project_for_web_automation_projects with MIT License 5 votes vote down vote up
private void verifyIfDriverIsOpera() {
    if(OPERA.equals(System.getProperty("context"))){
        OperaOptions operaOptions = new OperaOptions();
        operaOptions.setBinary(System.getProperty("binary"));
        BrowseTheWeb.as(theActorCalled(CESAR)).setDriver(new OperaDriver(operaOptions));
    }
}
 
Example #5
Source File: OperaDriverHandler.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 {
    OperaOptions operaOptions = new OperaOptions();

    if (parameter != null) {
        // @Arguments
        Arguments arguments = parameter.getAnnotation(Arguments.class);
        if (arguments != null) {
            stream(arguments.value()).forEach(operaOptions::addArguments);
        }

        // @Extensions
        Extensions extensions = parameter.getAnnotation(Extensions.class);
        if (extensions != null) {
            for (String extension : extensions.value()) {
                operaOptions.addExtensions(getExtension(extension));
            }
        }

        // @Binary
        Binary binary = parameter.getAnnotation(Binary.class);
        if (binary != null) {
            operaOptions.setBinary(binary.value());
        }

        // @Options
        OperaOptions optionsFromAnnotatedField = annotationsReader
                .getFromAnnotatedField(testInstance, Options.class,
                        OperaOptions.class);
        if (optionsFromAnnotatedField != null) {
            operaOptions = optionsFromAnnotatedField.merge(operaOptions);
        }
    }

    return operaOptions;
}
 
Example #6
Source File: OperaAnnotationReaderTest.java    From selenium-jupiter with Apache License 2.0 5 votes vote down vote up
@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"));
}
 
Example #7
Source File: OperaAnnotationReaderTest.java    From selenium-jupiter with Apache License 2.0 5 votes vote down vote up
@Test
void testAnnotatedOperaOptionsIsSelectedOverOtherAnnotatedOptions()
        throws Exception {
    Optional<Object> testInstance = Optional
            .of(new ClassWithMultipleOptions());
    OperaOptions operaOptions = (OperaOptions) annotationsReader
            .getOptions(null, testInstance);
    assertThat(operaOptions, notNullValue());
}
 
Example #8
Source File: CustomDriverProvider.java    From akita with Apache License 2.0 5 votes vote down vote up
/**
 * Задает options для запуска Opera драйвера
 * options можно передавать, как системную переменную, например -Doptions=--load-extension=my-custom-extension
 *
 * @return operaOptions
 */
private OperaOptions getOperaDriverOptions(DesiredCapabilities capabilities) {
    log.info("---------------Opera Driver---------------------");
    OperaOptions operaOptions = !options[0].equals("") ? new OperaOptions().addArguments(options) : new OperaOptions();
    operaOptions.setCapability(CapabilityType.BROWSER_VERSION, loadSystemPropertyOrDefault(CapabilityType.BROWSER_VERSION, VERSION_LATEST));
    operaOptions.merge(capabilities);
    return operaOptions;
}
 
Example #9
Source File: CustomDriverProvider.java    From akita with Apache License 2.0 5 votes vote down vote up
/**
 * Задает options для запуска Opera драйвера в контейнере Selenoid
 * options можно передавать, как системную переменную, например -Doptions=--load-extension=my-custom-extension
 *
 * @return operaOptions
 */
private OperaOptions getOperaRemoteDriverOptions(DesiredCapabilities capabilities) {
    log.info("---------------Opera Driver---------------------");
    OperaOptions operaOptions = !this.options[0].equals("") ? (new OperaOptions()).addArguments(this.options) : new OperaOptions();
    operaOptions.setCapability("browserVersion", PropertyLoader.loadSystemPropertyOrDefault("browserVersion", "latest"));
    operaOptions.setCapability("browserName", "opera");
    operaOptions.setBinary(PropertyLoader.loadSystemPropertyOrDefault("webdriver.opera.driver", "/usr/bin/opera"));
    operaOptions.merge(capabilities);
    return operaOptions;
}
 
Example #10
Source File: OperaUser.java    From openvidu with Apache License 2.0 5 votes vote down vote up
public OperaUser(String userName, int timeOfWaitInSeconds) {
	super(userName, timeOfWaitInSeconds);

	OperaOptions options = new OperaOptions();
	options.setBinary("/usr/bin/opera");
	DesiredCapabilities capabilities = DesiredCapabilities.operaBlink();
	capabilities.setAcceptInsecureCerts(true);
	capabilities.setCapability(CapabilityType.UNEXPECTED_ALERT_BEHAVIOUR, UnexpectedAlertBehaviour.IGNORE);

	options.addArguments("--use-fake-ui-for-media-stream");
	options.addArguments("--use-fake-device-for-media-stream");
	capabilities.setCapability(OperaOptions.CAPABILITY, options);

	String REMOTE_URL = System.getProperty("REMOTE_URL_OPERA");
	if (REMOTE_URL != null) {
		log.info("Using URL {} to connect to remote web driver", REMOTE_URL);
		try {
			this.driver = new RemoteWebDriver(new URL(REMOTE_URL), capabilities);
		} catch (MalformedURLException e) {
			e.printStackTrace();
		}
	} else {
		log.info("Using local web driver");
		this.driver = new OperaDriver(capabilities);
	}

	this.driver.manage().timeouts().setScriptTimeout(this.timeOfWaitInSeconds, TimeUnit.SECONDS);
	this.configureDriver();
}
 
Example #11
Source File: TestOperaBlinkDriver.java    From selenium with Apache License 2.0 5 votes vote down vote up
private static Capabilities operaWithCustomCapabilities(Capabilities originalCapabilities) {
  OperaOptions options = new OperaOptions();
  options.addArguments("disable-extensions");
  String operaPath = System.getProperty("webdriver.opera.binary");
  if (operaPath != null) {
    options.setBinary(new File(operaPath));
  }

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

  return options;
}
 
Example #12
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 #13
Source File: WebDriverTypeTests.java    From vividus with Apache License 2.0 4 votes vote down vote up
@Test
@PrepareForTest(fullyQualifiedNames = "org.vividus.selenium.WebDriverType$6")
public void testGetOperaWebDriver() throws Exception
{
    testGetOperaWebDriver(new WebDriverConfiguration(), new OperaOptions());
}
 
Example #14
Source File: DockerDriverHandler.java    From selenium-jupiter with Apache License 2.0 4 votes vote down vote up
private DesiredCapabilities getCapabilities(BrowserInstance browserInstance,
        boolean enableVnc) throws IllegalAccessException, IOException {
    DesiredCapabilities capabilities = browserInstance.getCapabilities();
    if (enableVnc) {
        capabilities.setCapability("enableVNC", true);
        capabilities.setCapability("screenResolution",
                getConfig().getVncScreenResolution());
    }

    if (getConfig().isRecording() || getConfig().isRecordingWhenFailure()) {
        capabilities.setCapability("enableVideo", true);
        capabilities.setCapability("videoScreenSize",
                getConfig().getRecordingVideoScreenSize());
        capabilities.setCapability("videoFrameRate",
                getConfig().getRecordingVideoFrameRate());
    }

    Optional<Capabilities> optionalCapabilities = annotationsReader != null
            ? annotationsReader.getCapabilities(parameter, testInstance)
            : Optional.of(new DesiredCapabilities());
    MutableCapabilities options = browserInstance.getDriverHandler()
            .getOptions(parameter, testInstance);

    // Due to bug in operablink the binary path must be set
    if (browserInstance.getBrowserType() == OPERA
            && browserVersion.equals("62.0")) {
        String operaBinaryPathLinux = getConfig().getOperaBinaryPathLinux();
        ((OperaOptions) options).setBinary(operaBinaryPathLinux);
        ChromeOptions chromeOptions = new ChromeOptions();
        chromeOptions.setBinary(operaBinaryPathLinux);

        OperaOptions operaOptions = new OperaOptions().merge(chromeOptions);
        operaOptions.setCapability("browserName", OPERA_NAME);
        options.merge(operaOptions);
        log.trace("Opera options: {}", options);
    }

    if (optionalCapabilities.isPresent()) {
        options.merge(optionalCapabilities.get());
    }
    capabilities.setCapability(browserInstance.getOptionsKey(), options);
    log.trace("Using {}", capabilities);
    return capabilities;
}
 
Example #15
Source File: OperaFactory.java    From webtester2-core with Apache License 2.0 4 votes vote down vote up
public OperaFactory() {
    super((capabilities) -> {
        OperaOptions operaOptions = new OperaOptions().merge(capabilities);
        return new OperaDriver(operaOptions);
    });
}
 
Example #16
Source File: DefaultLocalDriverProvider.java    From webdriver-factory with Apache License 2.0 4 votes vote down vote up
public WebDriver createDriver(OperaOptions options) {
  return new OperaDriver(options);
}