CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/maven-org-seleniumhq-selenium--selenium-firefox-driver

Selenium Firefox WebDriver implementation for automating Firefox browser interactions

Pending
Overview
Eval results
Files

profile-management.mddocs/

Profile Management

Firefox user profile creation, customization, and management including preferences, extensions, and certificate handling. The FirefoxProfile class provides comprehensive control over Firefox user data and behavior.

Capabilities

FirefoxProfile Class

Represents a Firefox user profile for customization and persistence of browser settings.

/**
 * Represents a Firefox user profile for customization.
 * Manages preferences, extensions, certificates, and user data.
 */
public class FirefoxProfile {
    
    /**
     * Creates a new Firefox profile with default settings.
     */
    public FirefoxProfile();
    
    /**
     * Creates a Firefox profile from an existing profile directory.
     * @param profileDir Existing Firefox profile directory
     */
    public FirefoxProfile(File profileDir);
}

Usage Examples:

import org.openqa.selenium.firefox.FirefoxProfile;
import java.io.File;

// Create new profile
FirefoxProfile profile = new FirefoxProfile();

// Load existing profile
File existingProfile = new File("/path/to/firefox/profile");
FirefoxProfile profile = new FirefoxProfile(existingProfile);

JSON Profile Creation

Creates profile instances from JSON representation for serialization scenarios.

/**
 * Creates a FirefoxProfile from JSON string representation.
 * @param json JSON string containing profile configuration
 * @return FirefoxProfile instance created from JSON
 */
public static FirefoxProfile fromJson(String json);

Preference Management

Gets and sets Firefox preferences with type-safe accessors.

/**
 * Gets a string preference value.
 * @param key Preference name
 * @param defaultValue Default value if preference not set
 * @return String preference value or default
 */
public String getStringPreference(String key, String defaultValue);

/**
 * Gets an integer preference value.
 * @param key Preference name  
 * @param defaultValue Default value if preference not set
 * @return Integer preference value or default
 */
public int getIntegerPreference(String key, int defaultValue);

/**
 * Gets a boolean preference value.
 * @param key Preference name
 * @param defaultValue Default value if preference not set  
 * @return Boolean preference value or default
 */
public boolean getBooleanPreference(String key, boolean defaultValue);

/**
 * Sets a Firefox preference value.
 * @param key Preference name (about:config key)
 * @param value Preference value (String, Integer, Boolean)
 */
public void setPreference(String key, Object value);

Usage Examples:

FirefoxProfile profile = new FirefoxProfile();

// Set various preference types
profile.setPreference("browser.startup.page", 1);  // Integer
profile.setPreference("browser.startup.homepage", "https://example.com");  // String
profile.setPreference("dom.webnotifications.enabled", false);  // Boolean

// Get preferences with defaults
String homepage = profile.getStringPreference("browser.startup.homepage", "about:blank");
int startupPage = profile.getIntegerPreference("browser.startup.page", 0);
boolean notifications = profile.getBooleanPreference("dom.webnotifications.enabled", true);

Extension Management

Manages Firefox extensions including installation from various sources.

/**
 * Checks if the profile contains the WebDriver extension.
 * @return true if WebDriver extension is present
 */
public boolean containsWebDriverExtension();

/**
 * Adds an extension from the classpath.
 * @param loadResourcesUsing Class to use for resource loading
 * @param loadFrom Classpath location of extension
 */
public void addExtension(Class<?> loadResourcesUsing, String loadFrom);

/**
 * Adds an extension from a file.
 * @param extensionToInstall Extension file (.xpi or directory)
 */
public void addExtension(File extensionToInstall);

/**
 * Adds an extension with a specific key.
 * @param key Extension identifier key
 * @param extension Extension implementation
 */
public void addExtension(String key, Extension extension);

Usage Examples:

FirefoxProfile profile = new FirefoxProfile();

// Add extension from file
File extensionFile = new File("/path/to/extension.xpi");
profile.addExtension(extensionFile);

// Add extension from classpath
profile.addExtension(MyClass.class, "/extensions/my-extension");

// Check for WebDriver extension
if (profile.containsWebDriverExtension()) {
    System.out.println("WebDriver extension is installed");
}

User Preferences File Management

Updates Firefox user preferences files directly.

/**
 * Updates user preferences file with current profile settings.
 * @param userPrefs Target user.js or prefs.js file
 */
public void updateUserPrefs(File userPrefs);

Cache and Cleanup Management

Manages Firefox cache and temporary files.

/**
 * Deletes extensions cache if it exists in the profile directory.
 * @param profileDir Profile directory to clean
 */
public void deleteExtensionsCacheIfItExists(File profileDir);

/**
 * Cleans the specified profile directory.
 * @param profileDir Profile directory to clean
 */
public void clean(File profileDir);

/**
 * Cleans temporary model files.
 */
public void cleanTemporaryModel();

Focus Library Configuration

Configures no-focus library loading for headless operation.

/**
 * Returns whether the no-focus library should be loaded.
 * @return true if no-focus library should be loaded
 */
public boolean shouldLoadNoFocusLib();

/**
 * Sets whether to always load the no-focus library.
 * @param loadNoFocusLib true to always load no-focus library
 */
public void setAlwaysLoadNoFocusLib(boolean loadNoFocusLib);

Certificate Management

Configures SSL certificate handling behavior.

/**
 * Sets whether to accept untrusted SSL certificates.
 * @param acceptUntrustedSsl true to accept untrusted certificates
 */
public void setAcceptUntrustedCertificates(boolean acceptUntrustedSsl);

/**
 * Sets whether to assume untrusted certificate issuers are acceptable.
 * @param untrustedIssuer true to assume untrusted issuers are acceptable  
 */
public void setAssumeUntrustedCertificateIssuer(boolean untrustedIssuer);

Profile Persistence

Writes the profile to disk for persistence and reuse.

/**
 * Writes the profile to disk and returns the directory location.
 * Creates a temporary directory if no existing directory is set.
 * @return File representing the profile directory on disk
 */
public File layoutOnDisk();

Complete Profile Configuration Example:

import org.openqa.selenium.firefox.FirefoxProfile;
import org.openqa.selenium.firefox.FirefoxOptions;
import java.io.File;

// Create and configure a comprehensive Firefox profile
FirefoxProfile profile = new FirefoxProfile();

// Set browser preferences
profile.setPreference("browser.startup.page", 0);
profile.setPreference("browser.startup.homepage", "about:blank");
profile.setPreference("browser.cache.disk.enable", false);
profile.setPreference("browser.cache.memory.enable", false);
profile.setPreference("dom.webnotifications.enabled", false);
profile.setPreference("media.navigator.permission.disabled", true);

// Download preferences
profile.setPreference("browser.download.folderList", 2);
profile.setPreference("browser.download.dir", "/tmp/downloads");
profile.setPreference("browser.helperApps.neverAsk.saveToDisk", 
    "application/pdf,application/zip,text/csv");

// Security preferences  
profile.setAcceptUntrustedCertificates(true);
profile.setAssumeUntrustedCertificateIssuer(false);

// Add extensions
File extensionFile = new File("/path/to/extension.xpi");
profile.addExtension(extensionFile);

// Configure for headless operation
profile.setAlwaysLoadNoFocusLib(true);

// Write profile to disk
File profileDir = profile.layoutOnDisk();
System.out.println("Profile created at: " + profileDir.getAbsolutePath());

// Use with FirefoxOptions
FirefoxOptions options = new FirefoxOptions().setProfile(profile);
WebDriver driver = new FirefoxDriver(options);

Install with Tessl CLI

npx tessl i tessl/maven-org-seleniumhq-selenium--selenium-firefox-driver

docs

browser-configuration.md

context-management.md

driver-management.md

extension-management.md

index.md

profile-management.md

screenshot-capabilities.md

service-management.md

tile.json