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


Java FirefoxOptions类代码示例

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


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

示例1: testFirefoxOptions

import org.openqa.selenium.firefox.FirefoxOptions; //导入依赖的package包/类
@ParameterizedTest
@MethodSource("testClassProvider")
@SuppressWarnings("unchecked")
void testFirefoxOptions(Class<?> testClass) throws Exception {
    Parameter parameter = testClass
            .getMethod("webrtcTest", FirefoxDriver.class)
            .getParameters()[0];
    Optional<Object> testInstance = Optional.of(testClass.newInstance());

    FirefoxOptions firefoxOptions = (FirefoxOptions) annotationsReader
            .getOptions(parameter, testInstance);
    Map<String, Map<String, Boolean>> options = (Map<String, Map<String, Boolean>>) firefoxOptions
            .asMap().get(FIREFOX_OPTIONS);

    assertTrue(options.get("prefs")
            .get("media.navigator.permission.disabled"));
    assertTrue(options.get("prefs").get("media.navigator.streams.fake"));
}
 
开发者ID:bonigarcia,项目名称:selenium-jupiter,代码行数:19,代码来源:FirefoxAnnotationReaderTest.java

示例2: settingBrowserSize

import org.openqa.selenium.firefox.FirefoxOptions; //导入依赖的package包/类
@Test
public void settingBrowserSize() {
    // given
    WebDriverProperties properties = new WebDriverProperties();
    properties.setProperty("browserSize", "1690x1000");

    // when
    Capabilities convertedCapabilities = firefoxCapabilitiesConverter.convert(properties);

    // then
    // expected safari options
    FirefoxOptions expectedFirefoxOptions = new FirefoxOptions();
    expectedFirefoxOptions.setCapability(CAPABILITY_AUTOCLOSE, false);
    expectedFirefoxOptions.setCapability(CAPABILITY_BROWSER_SIZE, "1690x1000");

    assertThat(convertedCapabilities.asMap()).isEqualTo(expectedFirefoxOptions.asMap());

}
 
开发者ID:isgarlo,项目名称:givemeadriver,代码行数:19,代码来源:FirefoxCapabilitiesConverterTest.java

示例3: resolve

import org.openqa.selenium.firefox.FirefoxOptions; //导入依赖的package包/类
@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);
    }
}
 
开发者ID:bonigarcia,项目名称:selenium-jupiter,代码行数:17,代码来源:FirefoxDriverHandler.java

示例4: getFirefoxOptions

import org.openqa.selenium.firefox.FirefoxOptions; //导入依赖的package包/类
private FirefoxOptions getFirefoxOptions() throws IOException {
    String driverPath = getProperty("browser.driver.path");
    if (!"".equals(driverPath)) {
        System.setProperty("webdriver.gecko.driver", driverPath);
    }
    FirefoxOptions options = new FirefoxOptions();
    options.setLogLevel(FirefoxDriverLogLevel.FATAL);
    FirefoxProfile profile = getProfile();
    if (profile == null) {
        String version = getProperty("browser.version");
        if (version != null) {
            options.setCapability("version", version);
        }
    } else {
        options.setProfile(profile);
    }
    return options;
}
 
开发者ID:sdl,项目名称:Testy,代码行数:19,代码来源:FirefoxConfigReader.java

示例5: configuration

import org.openqa.selenium.firefox.FirefoxOptions; //导入依赖的package包/类
@Override
public Capabilities configuration(final XmlConfig config) {
    final FirefoxOptions options = new FirefoxOptions();
    options.setCapability("enableVNC", true);
    options.setCapability("name", config.getTestName());
    options.setCapability("screenResolution", "1280x1024x24");
    return merge(config, options);
}
 
开发者ID:sskorol,项目名称:qaa-amazon,代码行数:9,代码来源:Firefox.java

示例6: 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

示例7: createOptions

import org.openqa.selenium.firefox.FirefoxOptions; //导入依赖的package包/类
protected FirefoxOptions createOptions()
{
    FirefoxOptions options = new FirefoxOptions();

    options.setProfile(createProfile());

    return options;
}
 
开发者ID:porscheinformatik,项目名称:selenium-components,代码行数:9,代码来源:FirefoxWebDriverFactory.java

示例8: convert

import org.openqa.selenium.firefox.FirefoxOptions; //导入依赖的package包/类
@Override
public Capabilities convert(WebDriverProperties properties) {
    FirefoxOptions firefoxOptions = new FirefoxOptions();

    // general options for logging purpose
    firefoxOptions.setCapability(CAPABILITY_AUTOCLOSE, properties.isAutoClose());
    addToFirefoxOptionsIfNoEmptyValue(firefoxOptions, CAPABILITY_DRIVER_VERSION, properties.getDriverVersion());
    addToFirefoxOptionsIfNoEmptyValue(firefoxOptions, CAPABILITY_BROWSER_SIZE, properties.getBrowserSize());

    return firefoxOptions;
}
 
开发者ID:isgarlo,项目名称:givemeadriver,代码行数:12,代码来源:FirefoxCapabilitiesConverter.java

示例9: getDriver

import org.openqa.selenium.firefox.FirefoxOptions; //导入依赖的package包/类
public static WebDriver getDriver() {
    if (instance == null) {
        instance = new DriverManager();
        instance.driver = new FirefoxDriver(new FirefoxOptions().setLegacy(true));
    }
    return instance.driver;
}
 
开发者ID:biblelamp,项目名称:QAExercises,代码行数:8,代码来源:DriverManager.java

示例10: setUp

import org.openqa.selenium.firefox.FirefoxOptions; //导入依赖的package包/类
@Before
public void setUp() {
    System.setProperty("webdriver.gecko.driver", "C:\\Program Files\\Java\\geckodriver.exe");
    driver = new FirefoxDriver(new FirefoxOptions().setLegacy(true));
    driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
    wait = new WebDriverWait(driver, 10);
}
 
开发者ID:biblelamp,项目名称:QAExercises,代码行数:8,代码来源:MatrixBoardAdminTest.java

示例11: 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

示例12: 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

示例13: allocateFirefoxDriver

import org.openqa.selenium.firefox.FirefoxOptions; //导入依赖的package包/类
@NotNull private static WebDriver allocateFirefoxDriver(Locale lang) throws IOException {
	FirefoxOptions fo = new FirefoxOptions();

	////-- Set the XDG_CONFIG_HOME envvar; this is used by fontconfig as one of its locations
	//File dir = createFontConfigFile();
	//FirefoxBinary ffb = new FirefoxBinary();
	//ffb.setEnvironmentProperty("XDG_CONFIG_HOME", dir.getParentFile().getAbsolutePath());
	//FirefoxOptions ffo = new FirefoxOptions(getFirefoxCapabilities(lang));
	//ffo.setBinary(ffb);
	//FirefoxDriver wd = new FirefoxDriver(ffo);

	replaceDotFonts();

	FirefoxDriver wd = new FirefoxDriver(getFirefoxCapabilities(lang));
	String browserName = wd.getCapabilities().getBrowserName();
	String version = wd.getCapabilities().getVersion();
	System.out.println("wd: allocated " + browserName + " " + version);
	return wd;
}
 
开发者ID:fjalvingh,项目名称:domui,代码行数:20,代码来源:WebDriverFactory.java

示例14: setupTest

import org.openqa.selenium.firefox.FirefoxOptions; //导入依赖的package包/类
@Before
public void setupTest() {
    FirefoxOptions options = new FirefoxOptions();

    // This flag avoids granting the access to the camera
    options.addPreference("media.navigator.permission.disabled", true);

    // This flag force to use fake user media (synthetic video of multiple
    // color)
    options.addPreference("media.navigator.streams.fake", true);

    driver = new FirefoxDriver(options);
}
 
开发者ID:bonigarcia,项目名称:webdrivermanager-examples,代码行数:14,代码来源:WebRtcFirefoxTest.java

示例15: VaadinLocaleTest

import org.openqa.selenium.firefox.FirefoxOptions; //导入依赖的package包/类
public VaadinLocaleTest(String language, String expectedLanuage) {
    this.expectedLanguage = expectedLanuage;
    FirefoxProfile profile = new FirefoxProfile();
    profile.setPreference("intl.accept_languages", language);
    FirefoxOptions firefoxOptions = new FirefoxOptions();
    firefoxOptions.setProfile(profile);
    WebDriver webDriver = new FirefoxDriver(firefoxOptions);
    startBrowser(webDriver);
}
 
开发者ID:viritin,项目名称:viritin,代码行数:10,代码来源:VaadinLocaleTest.java


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