Selenium Firefox WebDriver implementation for automating Firefox browser interactions
npx @tessl/cli install tessl/maven-org-seleniumhq-selenium--selenium-firefox-driver@4.33.0The Selenium Firefox WebDriver provides comprehensive automation capabilities for Mozilla Firefox browsers. This library offers a complete WebDriver implementation with Firefox-specific features including profile management, extension handling, full-page screenshots, and modern WebDriver BiDi protocol support.
org.seleniumhq.selenium:selenium-firefox-driver:4.33.0<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-firefox-driver</artifactId>
<version>4.33.0</version>
</dependency>import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.firefox.FirefoxOptions;
import org.openqa.selenium.firefox.FirefoxProfile;
import org.openqa.selenium.firefox.GeckoDriverService;import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.firefox.FirefoxOptions;
import org.openqa.selenium.WebDriver;
// Basic Firefox driver creation
WebDriver driver = new FirefoxDriver();
// Firefox driver with options
FirefoxOptions options = new FirefoxOptions()
.addPreference("browser.startup.page", 1)
.addPreference("browser.startup.homepage", "https://example.com")
.setAcceptInsecureCerts(true)
.setHeadless(true);
WebDriver driver = new FirefoxDriver(options);
// Navigate and interact
driver.get("https://example.com");
String title = driver.getTitle();
// Clean up
driver.quit();The Firefox WebDriver is built around several key components:
Core Firefox WebDriver functionality including driver instantiation, configuration, and lifecycle management. Supports both local and remote execution modes.
// Main driver class
public class FirefoxDriver extends RemoteWebDriver
implements WebStorage, HasExtensions, HasFullPageScreenshot, HasContext, HasBiDi {
public FirefoxDriver();
public FirefoxDriver(FirefoxOptions options);
public FirefoxDriver(FirefoxDriverService service);
public FirefoxDriver(FirefoxDriverService service, FirefoxOptions options);
public static RemoteWebDriverBuilder builder();
// System properties for configuration
public static final class SystemProperty {
public static final String BROWSER_BINARY = "webdriver.firefox.bin";
public static final String BROWSER_PROFILE = "webdriver.firefox.profile";
}
}Comprehensive configuration system for Firefox browser settings, preferences, command-line arguments, and capabilities. Includes Android device support and advanced options.
public class FirefoxOptions extends AbstractDriverOptions<FirefoxOptions> {
public FirefoxOptions();
public FirefoxOptions addPreference(String key, Object value);
public FirefoxOptions addArguments(String... arguments);
public FirefoxOptions setBinary(Path path);
public FirefoxOptions setProfile(FirefoxProfile profile);
public FirefoxOptions setLogLevel(FirefoxDriverLogLevel logLevel);
}Firefox user profile creation, customization, and management including preferences, extensions, and certificate handling.
public class FirefoxProfile {
public FirefoxProfile();
public FirefoxProfile(File profileDir);
public void setPreference(String key, Object value);
public void addExtension(File extensionToInstall);
public File layoutOnDisk();
}GeckoDriver service lifecycle management including executable location, logging configuration, and process control.
public class GeckoDriverService extends DriverService {
public static GeckoDriverService createDefaultService();
public static class Builder extends DriverService.Builder<GeckoDriverService, Builder> {
public Builder withLogLevel(FirefoxDriverLogLevel logLevel);
}
}Browser extension installation, management, and removal with support for temporary and permanent extensions.
public interface HasExtensions {
String installExtension(Path path);
String installExtension(Path path, Boolean temporary);
void uninstallExtension(String extensionId);
}Full-page screenshot functionality beyond standard WebDriver screenshot capabilities.
public interface HasFullPageScreenshot {
<X> X getFullPageScreenshotAs(OutputType<X> outputType);
}Firefox-specific context switching between content and chrome contexts for advanced browser automation scenarios.
public interface HasContext {
void setContext(FirefoxCommandContext context);
FirefoxCommandContext getContext();
}
public enum FirefoxCommandContext {
CONTENT("content"),
CHROME("chrome");
}// Log levels for GeckoDriver
public enum FirefoxDriverLogLevel {
TRACE, DEBUG, CONFIG, INFO, WARN, ERROR, FATAL;
public static FirefoxDriverLogLevel fromString(String text);
public Map<String, String> toJson();
}
// Exception for profile creation failures
public class UnableToCreateProfileException extends WebDriverException {
public UnableToCreateProfileException(String message);
public UnableToCreateProfileException(Throwable cause);
}
// Extension interface
public interface Extension {
void writeTo(File parentDirectory);
}