Java Code Examples for org.openqa.selenium.firefox.FirefoxOptions#merge()

The following examples show how to use org.openqa.selenium.firefox.FirefoxOptions#merge() . 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: FirefoxDevice.java    From agent with MIT License 6 votes vote down vote up
@Override
protected Capabilities newCaps(Capabilities capsToMerge) {
    FirefoxOptions firefoxOptions = new FirefoxOptions();
    firefoxOptions.setAcceptInsecureCerts(true);

    // **** 以上capabilities可被传入的caps覆盖 ****

    firefoxOptions.merge(capsToMerge);

    // **** 以下capabilities具有更高优先级,将覆盖传入的caps ****

    if (!StringUtils.isEmpty(browser.getPath())) {
        firefoxOptions.setBinary(browser.getPath());
    }

    return firefoxOptions;
}
 
Example 2
Source File: FirefoxDriverHandler.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);
        FirefoxOptions firefoxOptions = (FirefoxOptions) getOptions(
                parameter, testInstance);
        if (capabilities.isPresent()) {
            firefoxOptions.merge(capabilities.get());
        }
        object = new FirefoxDriver(firefoxOptions);
    } catch (Exception e) {
        handleException(e);
    }
}
 
Example 3
Source File: FireFoxCaps.java    From teasy with MIT License 5 votes vote down vote up
public FirefoxOptions get() {
    FirefoxOptions firefoxOptions = getFirefoxOptions();
    if (!this.customCaps.asMap().isEmpty()) {
        firefoxOptions.merge(this.customCaps);
    }
    return firefoxOptions;
}
 
Example 4
Source File: GeckoCaps.java    From teasy with MIT License 5 votes vote down vote up
public FirefoxOptions get() {
    FirefoxOptions caps = getGeckoOptions();
    if (!this.customCaps.asMap().isEmpty()) {
        caps.merge(this.customCaps);
    }
    return caps;
}
 
Example 5
Source File: SetProxyForWebDriver.java    From neodymium-library with MIT License 5 votes vote down vote up
@Test
public void testFirefox()
{
    DesiredCapabilities capabilities = createCapabilitiesWithProxy();
    FirefoxOptions options = new FirefoxOptions();
    options.merge(capabilities);

    Assert.assertTrue(options.getCapability(CapabilityType.PROXY) != null);
}
 
Example 6
Source File: CustomDriverProvider.java    From akita with Apache License 2.0 5 votes vote down vote up
/**
 * Задает options для запуска Firefox драйвера
 * options можно передавать, как системную переменную, например -Doptions=--load-extension=my-custom-extension
 *
 * @return FirefoxOptions
 */
private FirefoxOptions getFirefoxDriverOptions(DesiredCapabilities capabilities) {
    log.info("---------------Firefox Driver---------------------");
    FirefoxOptions firefoxOptions = !options[0].equals("") ? new FirefoxOptions().addArguments(options) : new FirefoxOptions();
    capabilities.setVersion(loadSystemPropertyOrDefault(CapabilityType.BROWSER_VERSION, VERSION_LATEST));
    firefoxOptions.setHeadless(getHeadless());
    firefoxOptions.merge(capabilities);
    return firefoxOptions;
}
 
Example 7
Source File: FirefoxDriverHandler.java    From selenium-jupiter with Apache License 2.0 4 votes vote down vote up
@Override
public MutableCapabilities getOptions(Parameter parameter,
        Optional<Object> testInstance)
        throws IOException, IllegalAccessException {
    FirefoxOptions firefoxOptions = new FirefoxOptions();

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

        // @Extensions
        Extensions extensions = parameter.getAnnotation(Extensions.class);
        if (extensions != null) {
            for (String extension : extensions.value()) {
                FirefoxProfile firefoxProfile = new FirefoxProfile();
                firefoxProfile.addExtension(getExtension(extension));
                firefoxOptions.setProfile(firefoxProfile);
            }
        }

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

        // @Preferences
        managePreferences(parameter, firefoxOptions);

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

    return firefoxOptions;
}