Java 类org.openqa.selenium.firefox.internal.FileExtension 实例源码

项目: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);
}