Java 类org.openqa.selenium.firefox.FirefoxOptions 实例源码

项目:selenium-jupiter    文件:FirefoxAnnotationReaderTest.java   
@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"));
}
项目:givemeadriver    文件:FirefoxCapabilitiesConverterTest.java   
@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());

}
项目:selenium-jupiter    文件:FirefoxDriverHandler.java   
@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);
    }
}
项目:domui    文件:WebDriverFactory.java   
@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;
}
项目:Testy    文件:FirefoxConfigReader.java   
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;
}
项目:qaa-amazon    文件:Firefox.java   
@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);
}
项目:webdriver-supplier    文件:Firefox.java   
@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);
}
项目:NoraUi    文件:DriverFactory.java   
/**
 * 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);
}
项目:selenium-components    文件:FirefoxWebDriverFactory.java   
protected FirefoxOptions createOptions()
{
    FirefoxOptions options = new FirefoxOptions();

    options.setProfile(createProfile());

    return options;
}
项目:givemeadriver    文件:FirefoxCapabilitiesConverter.java   
@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;
}
项目:QAExercises    文件:DriverManager.java   
public static WebDriver getDriver() {
    if (instance == null) {
        instance = new DriverManager();
        instance.driver = new FirefoxDriver(new FirefoxOptions().setLegacy(true));
    }
    return instance.driver;
}
项目:QAExercises    文件:DriverManager.java   
public static WebDriver getDriver() {
    if (instance == null) {
        instance = new DriverManager();
        instance.driver = new FirefoxDriver(new FirefoxOptions().setLegacy(true));
    }
    return instance.driver;
}
项目:QAExercises    文件:MatrixBoardAdminTest.java   
@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);
}
项目:willtest    文件:LocalFirefoxProvider.java   
@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);
}
项目:teiniker-lectures-practicalsoftwareengineering    文件:FirefoxTest.java   
@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);
}
项目:webdrivermanager-examples    文件:WebRtcFirefoxTest.java   
@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);
}
项目:viritin    文件:VaadinLocaleTest.java   
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);
}
项目:viritin    文件:MBeanFieldGroupRequiredErrorMessageTest.java   
public MBeanFieldGroupRequiredErrorMessageTest(String language, String expectedMessage) {
    this.expectedMessage = expectedMessage;
    FirefoxProfile profile = new FirefoxProfile();
    profile.setPreference("intl.accept_languages", language);
    FirefoxOptions firefoxOptions = new FirefoxOptions();
    firefoxOptions.setProfile(profile);
    WebDriver webDriver = new FirefoxDriver(firefoxOptions);
    startBrowser(webDriver);
}
项目:minium    文件:WebDriverFactory.java   
@Override
public WebDriver create(WebDriverFactory webDriverFactory, DesiredCapabilities desiredCapabilities) {
    FirefoxDriverServiceProperties serviceProperties = webDriverFactory.driverServices == null ? null : webDriverFactory.driverServices.getFirefox();
    DriverService driverService = serviceProperties == null ? null : serviceProperties.getDriverService();
    FirefoxOptions firefoxOptions = new FirefoxOptions().merge(desiredCapabilities);
    return driverService == null ? new FirefoxDriver(firefoxOptions) : new RemoteWebDriver(driverService.getUrl(), firefoxOptions);
}
项目:minium    文件:WebDriverFactory.java   
private Capabilities firefoxCapabilities(FirefoxProfileProperties firefoxProperties) throws IOException {
    File profileDirectory = null;
    String profileDir = firefoxProperties.getDir();
    if (profileDir != null) {
        profileDirectory = new File(profileDir);
    }
    FirefoxProfile profile = new FirefoxProfile(profileDirectory);

    List<PreferenceProperties> preferences = firefoxProperties.getPreferences();
    if (preferences != null) {
        for (PreferenceProperties preference : preferences) {
            switch (preference.getType()) {
            case BOOLEAN:
                profile.setPreference(preference.getName(), (Boolean) preference.getValue());
                break;
            case INTEGER:
                profile.setPreference(preference.getName(), (Integer) preference.getValue());
                break;
            case STRING:
                profile.setPreference(preference.getName(), (String) preference.getValue());
            }
        }
    }

    List<ExtensionProperties> extensions = firefoxProperties.getExtensions();
    if (extensions != null) {
        DefaultResourceLoader resourceLoader = new DefaultResourceLoader();
        for (ExtensionProperties firefoxExtension : extensions) {
            Resource extensionPath = resourceLoader.getResource(firefoxExtension.getPath());
            FileExtension extension = new FileExtension(extensionPath.getFile());
            profile.addExtension(firefoxExtension.getName(), extension);
        }
    }

    profile.setAlwaysLoadNoFocusLib(firefoxProperties.shouldLoadNoFocusLib());
    profile.setAcceptUntrustedCertificates(firefoxProperties.shouldAcceptUntrustedCerts());
    profile.setAssumeUntrustedCertificateIssuer(firefoxProperties.shouldUntrustedCertIssuer());

    return new FirefoxOptions().setProfile(profile);
}
项目:Testy    文件:FirefoxConfigReader.java   
@Override
public WebDriver createDriver(URL remoteUrl) throws IOException {
    FirefoxOptions options = getFirefoxOptions();
    if (isRemoteDriver()) {
        RemoteWebDriver driver = new RemoteWebDriver(remoteUrl, options);
        driver.setFileDetector(new LocalFileDetector());
        return driver;
    } else {
        return new FirefoxDriver(options);
    }
}
项目:saladium    文件:LocalDriver.java   
public LocalDriver(FirefoxOptions options) {
//        System.setProperty("webdriver.gecko.driver", "geckodriver");
//        setDriver(new FirefoxDriver(options));
    }
项目:ats-framework    文件:UiEngineConfigurator.java   
/**
 * @return the Firefox options
 */
@PublicAtsApi
public FirefoxOptions getFirefoxDriverOptions() {

    return firefoxOptions;
}
项目:ats-framework    文件:UiEngineConfigurator.java   
/**
 * Pass options which will be applied when starting a Firefox broswer through Selenium
 * @param options Firefox options
 */
@PublicAtsApi
public void setFirefoxDriverOptions( FirefoxOptions options ) {

    firefoxOptions = options;
}
项目:KITE    文件:WebDriverFactory.java   
/**
 * Creates a Capabilities object based on the given Browser object.
 *
 * @param browser Browser
 * @param testName name for individual test case
 * @return Capabilities
 */
private static Capabilities createCapabilities(Browser browser, String testName) {

  DesiredCapabilities capabilities = new DesiredCapabilities();

  capabilities.setBrowserName(browser.getBrowserName());
  if (browser.getVersion() != null)
    capabilities.setVersion(browser.getVersion());
  if (browser.getPlatform() != null)
    capabilities.setCapability("platform", browser.getPlatform());
  // Remote test identifier
  capabilities.setCapability("name", testName);

  switch (browser.getBrowserName()) {
    case "chrome":
      // capabilities = DesiredCapabilities.chrome();
      ChromeOptions chromeOptions = new ChromeOptions();
      chromeOptions.addArguments("use-fake-ui-for-media-stream");
      chromeOptions.addArguments("use-fake-device-for-media-stream");
      /*
       * chromeOptions.addArguments("no-sandbox"); chromeOptions.addArguments("disable-infobars");
       * chromeOptions.addArguments("test-type=browser");
       * chromeOptions.addArguments("disable-extensions");
       * chromeOptions.addArguments("--js-flags=--expose-gc");
       * chromeOptions.addArguments("--disable-default-apps");
       * chromeOptions.addArguments("--disable-popup-blocking");
       * chromeOptions.addArguments("--enable-precise-memory-info");
       */
      capabilities.setCapability(ChromeOptions.CAPABILITY, chromeOptions);
      break;
    case "firefox":
      // capabilities = DesiredCapabilities.firefox();
      FirefoxProfile firefoxProfile = new FirefoxProfile();
      firefoxProfile.setPreference("media.navigator.streams.fake", true);
      FirefoxOptions firefoxOptions = new FirefoxOptions();
      firefoxOptions.setProfile(firefoxProfile);
      capabilities.merge(firefoxOptions.toCapabilities());
      /*
       * capabilities.setCapability(FirefoxDriver.PROFILE, firefoxProfile);
       */
      break;
    case "MicrosoftEdge":
      // capabilities = DesiredCapabilities.edge();
      capabilities.setCapability("avoidProxy", true);
      break;
    case "safari":
      // capabilities = DesiredCapabilities.safari();
      SafariOptions options = new SafariOptions();
      options.setUseTechnologyPreview(true);
      capabilities.setCapability(SafariOptions.CAPABILITY, options);
      break;
  }

  // Capabilities for mobile browsers
  Mobile mobile = browser.getMobile();
  if (mobile != null) {
    capabilities.setCapability("deviceName", mobile.getDeviceName());
    capabilities.setCapability("platformName", mobile.getPlatformName());
    capabilities.setCapability("platformVersion", mobile.getPlatformVersion());
    if (mobile.getPlatformName().equalsIgnoreCase("iOS")) {
      capabilities.setCapability("automationName", "XCUITest");
    } else {
      capabilities.setCapability("autoGrantPermissions", true);
      capabilities.setCapability("noReset", true);
    }
  }

  return capabilities;

}
项目:givemeadriver    文件:FirefoxCapabilitiesConverter.java   
private void addToFirefoxOptionsIfNoEmptyValue(FirefoxOptions firefoxOptions, String key, String value) {
    if (isNotEmpty(value)) {
        firefoxOptions.setCapability(key, value);
    }
}
项目:givemeadriver    文件:FirefoxDriverFactory.java   
@Override
public WebDriver createDriver(Capabilities capabilities) {
    String driverVersion = (String) capabilities.getCapability(CAPABILITY_DRIVER_VERSION);
    FirefoxDriverManager.getInstance().version(driverVersion).setup();
    return new FirefoxDriver((FirefoxOptions) capabilities);
}
项目:selenium-jupiter    文件:FirefoxDriverHandler.java   
@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;
}
项目:easyium-java    文件:FirefoxDriver.java   
public FirefoxDriver(FirefoxOptions options) {
    super(new org.openqa.selenium.firefox.FirefoxDriver(options));
}
项目:enmasse    文件:FirefoxWebConsoleTest.java   
@Override
public WebDriver buildDriver() {
    FirefoxOptions opts = new FirefoxOptions();
    opts.setHeadless(true);
    return new FirefoxDriver(opts);
}
项目:enmasse    文件:FirefoxWebConsoleTest.java   
@Override
public WebDriver buildDriver() {
    FirefoxOptions opts = new FirefoxOptions();
    opts.setHeadless(true);
    return new FirefoxDriver(opts);
}
项目:enmasse    文件:FirefoxWebConsoleTest.java   
@Override
public WebDriver buildDriver() {
    FirefoxOptions opts = new FirefoxOptions();
    opts.setHeadless(true);
    return new FirefoxDriver(opts);
}
项目:openmeetings    文件:AbstractTestDefaults.java   
@Before
public void setUp() {
    FirefoxProfile profile = new FirefoxProfile();
    profile.setPreference("intl.accept_languages", getLocale());
    driver = new FirefoxDriver(new FirefoxOptions().setProfile(profile));
}
项目:JDI    文件:SeleniumDriverFactory.java   
public FirefoxOptions defaultFirefoxOptions() {
    FirefoxOptions cap = new FirefoxOptions();
    return (FirefoxOptions) modifyCapabilities.apply(cap);
}
项目:frameworkium-core    文件:LegacyFirefoxImpl.java   
@Override
public FirefoxOptions getCapabilities() {
    FirefoxOptions firefoxOptions = new FirefoxOptions();
    firefoxOptions.setLegacy(true);
    return firefoxOptions;
}
项目:frameworkium-core    文件:CustomFirefoxImpl.java   
@Override
public Capabilities getCapabilities() {
    return new FirefoxOptions();
}
项目:frameworkium-core    文件:CustomFirefoxImpl.java   
@Override
public WebDriver getWebDriver(Capabilities capabilities) {
    return new FirefoxDriver(new FirefoxOptions(capabilities));
}
项目:Testy    文件:FirefoxConfigReader.java   
@Override
public WebDriver createDriver() throws IOException {
    FirefoxOptions options = getFirefoxOptions();
    return new FirefoxDriver(options);
}
项目:kabo    文件:Options.java   
public abstract FirefoxOptions fireOptions();