当前位置: 首页>>代码示例>>Java>>正文


Java FirefoxOptions.setBinary方法代码示例

本文整理汇总了Java中org.openqa.selenium.firefox.FirefoxOptions.setBinary方法的典型用法代码示例。如果您正苦于以下问题:Java FirefoxOptions.setBinary方法的具体用法?Java FirefoxOptions.setBinary怎么用?Java FirefoxOptions.setBinary使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.openqa.selenium.firefox.FirefoxOptions的用法示例。


在下文中一共展示了FirefoxOptions.setBinary方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: generateFirefoxDriver

import org.openqa.selenium.firefox.FirefoxOptions; //导入方法依赖的package包/类
/**
 * Generates a firefox webdriver.
 *
 * @return
 *         A firefox webdriver
 * @throws TechnicalException
 *             if an error occured when Webdriver setExecutable to true.
 */
private WebDriver generateFirefoxDriver() throws TechnicalException {
    final String pathWebdriver = DriverFactory.getPath(Driver.FIREFOX);
    if (!new File(pathWebdriver).setExecutable(true)) {
        throw new TechnicalException(Messages.getMessage(TechnicalException.TECHNICAL_ERROR_MESSAGE_WEBDRIVER_SET_EXECUTABLE));
    }
    logger.info("Generating Firefox driver ({}) ...", pathWebdriver);

    System.setProperty(Driver.FIREFOX.getDriverName(), pathWebdriver);

    final FirefoxOptions firefoxOptions = new FirefoxOptions();
    final FirefoxBinary firefoxBinary = new FirefoxBinary();

    final DesiredCapabilities capabilities = DesiredCapabilities.firefox();
    capabilities.setCapability(CapabilityType.ForSeleniumServer.ENSURING_CLEAN_SESSION, true);
    capabilities.setCapability(CapabilityType.UNEXPECTED_ALERT_BEHAVIOUR, UnexpectedAlertBehaviour.ACCEPT);

    setLoggingLevel(capabilities);

    // Proxy configuration
    if (Context.getProxy().getProxyType() != ProxyType.UNSPECIFIED && Context.getProxy().getProxyType() != ProxyType.AUTODETECT) {
        capabilities.setCapability(CapabilityType.PROXY, Context.getProxy());
    }

    if (Context.isHeadless()) {
        firefoxBinary.addCommandLineOptions("--headless");
        firefoxOptions.setBinary(firefoxBinary);
    }
    firefoxOptions.setLogLevel(Level.OFF);

    capabilities.setCapability(FirefoxOptions.FIREFOX_OPTIONS, firefoxOptions);

    return new FirefoxDriver(capabilities);
}
 
开发者ID:NoraUi,项目名称:NoraUi,代码行数:42,代码来源:DriverFactory.java

示例2: constructWebDriver

import org.openqa.selenium.firefox.FirefoxOptions; //导入方法依赖的package包/类
@Override
protected FirefoxDriver constructWebDriver(DesiredCapabilities desiredCapabilities) {
    FirefoxBinary firefoxBinary = getFirefoxConfiguration().getFirefoxBinary();
    FirefoxProfile profile = getFirefoxConfiguration().getFirefoxProfile();
    FirefoxOptions firefoxOptions = new FirefoxOptions();
    firefoxOptions.setBinary(firefoxBinary);
    firefoxOptions.setProfile(profile);
    return new FirefoxDriver(firefoxOptions);
}
 
开发者ID:willhaben,项目名称:willtest,代码行数:10,代码来源:LocalFirefoxProvider.java

示例3: setUp

import org.openqa.selenium.firefox.FirefoxOptions; //导入方法依赖的package包/类
@Before
public void setUp() throws Exception
{
    FirefoxOptions options = new FirefoxOptions();
    options.setBinary("/usr/bin/firefox");
    DesiredCapabilities capabilities = DesiredCapabilities.firefox();
    capabilities.setCapability("marionette", false);
    capabilities.setCapability("moz:firefoxOptions", options);
    driver = new FirefoxDriver(capabilities);

    driver.manage().timeouts().pageLoadTimeout(10, TimeUnit.SECONDS);
    driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
}
 
开发者ID:teiniker,项目名称:teiniker-lectures-practicalsoftwareengineering,代码行数:14,代码来源:FirefoxTest.java

示例4: getOptions

import org.openqa.selenium.firefox.FirefoxOptions; //导入方法依赖的package包/类
@Override
public MutableCapabilities getOptions(Parameter parameter,
        Optional<Object> testInstance)
        throws IOException, IllegalAccessException {
    FirefoxOptions firefoxOptions = new FirefoxOptions();

    // @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
    Object optionsFromAnnotatedField = annotationsReader
            .getOptionsFromAnnotatedField(testInstance, Options.class);
    if (optionsFromAnnotatedField != null) {
        firefoxOptions = ((FirefoxOptions) optionsFromAnnotatedField)
                .merge(firefoxOptions);
    }

    return firefoxOptions;
}
 
开发者ID:bonigarcia,项目名称:selenium-jupiter,代码行数:42,代码来源:FirefoxDriverHandler.java


注:本文中的org.openqa.selenium.firefox.FirefoxOptions.setBinary方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。