Selenium Firefox WebDriver implementation for automating Firefox browser interactions
npx @tessl/cli install tessl/maven-org-seleniumhq-selenium--selenium-firefox-driver@4.33.00
# Selenium Firefox WebDriver
1
2
The 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.
3
4
## Package Information
5
6
- **Package Name**: selenium-firefox-driver
7
- **Package Type**: maven
8
- **Language**: Java
9
- **Maven Coordinates**: `org.seleniumhq.selenium:selenium-firefox-driver:4.33.0`
10
- **Installation**: Add to Maven dependencies:
11
12
```xml
13
<dependency>
14
<groupId>org.seleniumhq.selenium</groupId>
15
<artifactId>selenium-firefox-driver</artifactId>
16
<version>4.33.0</version>
17
</dependency>
18
```
19
20
## Core Imports
21
22
```java
23
import org.openqa.selenium.firefox.FirefoxDriver;
24
import org.openqa.selenium.firefox.FirefoxOptions;
25
import org.openqa.selenium.firefox.FirefoxProfile;
26
import org.openqa.selenium.firefox.GeckoDriverService;
27
```
28
29
## Basic Usage
30
31
```java
32
import org.openqa.selenium.firefox.FirefoxDriver;
33
import org.openqa.selenium.firefox.FirefoxOptions;
34
import org.openqa.selenium.WebDriver;
35
36
// Basic Firefox driver creation
37
WebDriver driver = new FirefoxDriver();
38
39
// Firefox driver with options
40
FirefoxOptions options = new FirefoxOptions()
41
.addPreference("browser.startup.page", 1)
42
.addPreference("browser.startup.homepage", "https://example.com")
43
.setAcceptInsecureCerts(true)
44
.setHeadless(true);
45
46
WebDriver driver = new FirefoxDriver(options);
47
48
// Navigate and interact
49
driver.get("https://example.com");
50
String title = driver.getTitle();
51
52
// Clean up
53
driver.quit();
54
```
55
56
## Architecture
57
58
The Firefox WebDriver is built around several key components:
59
60
- **FirefoxDriver**: Main WebDriver implementation extending RemoteWebDriver with Firefox-specific capabilities
61
- **GeckoDriverService**: Manages the GeckoDriver executable lifecycle and communication
62
- **FirefoxOptions**: Configuration builder for browser settings, preferences, and capabilities
63
- **FirefoxProfile**: User profile management for customization and extension handling
64
- **Context Management**: Switching between content and chrome contexts for advanced automation
65
- **Extension System**: Installing and managing Firefox browser extensions
66
- **BiDi Protocol**: Modern WebDriver BiDi support for advanced browser automation
67
68
## Capabilities
69
70
### Driver Management
71
72
Core Firefox WebDriver functionality including driver instantiation, configuration, and lifecycle management. Supports both local and remote execution modes.
73
74
```java { .api }
75
// Main driver class
76
public class FirefoxDriver extends RemoteWebDriver
77
implements WebStorage, HasExtensions, HasFullPageScreenshot, HasContext, HasBiDi {
78
79
public FirefoxDriver();
80
public FirefoxDriver(FirefoxOptions options);
81
public FirefoxDriver(FirefoxDriverService service);
82
public FirefoxDriver(FirefoxDriverService service, FirefoxOptions options);
83
public static RemoteWebDriverBuilder builder();
84
85
// System properties for configuration
86
public static final class SystemProperty {
87
public static final String BROWSER_BINARY = "webdriver.firefox.bin";
88
public static final String BROWSER_PROFILE = "webdriver.firefox.profile";
89
}
90
}
91
```
92
93
[Driver Management](./driver-management.md)
94
95
### Browser Configuration
96
97
Comprehensive configuration system for Firefox browser settings, preferences, command-line arguments, and capabilities. Includes Android device support and advanced options.
98
99
```java { .api }
100
public class FirefoxOptions extends AbstractDriverOptions<FirefoxOptions> {
101
public FirefoxOptions();
102
public FirefoxOptions addPreference(String key, Object value);
103
public FirefoxOptions addArguments(String... arguments);
104
public FirefoxOptions setBinary(Path path);
105
public FirefoxOptions setProfile(FirefoxProfile profile);
106
public FirefoxOptions setLogLevel(FirefoxDriverLogLevel logLevel);
107
}
108
```
109
110
[Browser Configuration](./browser-configuration.md)
111
112
### Profile Management
113
114
Firefox user profile creation, customization, and management including preferences, extensions, and certificate handling.
115
116
```java { .api }
117
public class FirefoxProfile {
118
public FirefoxProfile();
119
public FirefoxProfile(File profileDir);
120
public void setPreference(String key, Object value);
121
public void addExtension(File extensionToInstall);
122
public File layoutOnDisk();
123
}
124
```
125
126
[Profile Management](./profile-management.md)
127
128
### Service Management
129
130
GeckoDriver service lifecycle management including executable location, logging configuration, and process control.
131
132
```java { .api }
133
public class GeckoDriverService extends DriverService {
134
public static GeckoDriverService createDefaultService();
135
public static class Builder extends DriverService.Builder<GeckoDriverService, Builder> {
136
public Builder withLogLevel(FirefoxDriverLogLevel logLevel);
137
}
138
}
139
```
140
141
[Service Management](./service-management.md)
142
143
### Extension Management
144
145
Browser extension installation, management, and removal with support for temporary and permanent extensions.
146
147
```java { .api }
148
public interface HasExtensions {
149
String installExtension(Path path);
150
String installExtension(Path path, Boolean temporary);
151
void uninstallExtension(String extensionId);
152
}
153
```
154
155
[Extension Management](./extension-management.md)
156
157
### Screenshot Capabilities
158
159
Full-page screenshot functionality beyond standard WebDriver screenshot capabilities.
160
161
```java { .api }
162
public interface HasFullPageScreenshot {
163
<X> X getFullPageScreenshotAs(OutputType<X> outputType);
164
}
165
```
166
167
[Screenshot Capabilities](./screenshot-capabilities.md)
168
169
### Context Management
170
171
Firefox-specific context switching between content and chrome contexts for advanced browser automation scenarios.
172
173
```java { .api }
174
public interface HasContext {
175
void setContext(FirefoxCommandContext context);
176
FirefoxCommandContext getContext();
177
}
178
179
public enum FirefoxCommandContext {
180
CONTENT("content"),
181
CHROME("chrome");
182
}
183
```
184
185
[Context Management](./context-management.md)
186
187
## Common Types
188
189
```java { .api }
190
// Log levels for GeckoDriver
191
public enum FirefoxDriverLogLevel {
192
TRACE, DEBUG, CONFIG, INFO, WARN, ERROR, FATAL;
193
194
public static FirefoxDriverLogLevel fromString(String text);
195
public Map<String, String> toJson();
196
}
197
198
// Exception for profile creation failures
199
public class UnableToCreateProfileException extends WebDriverException {
200
public UnableToCreateProfileException(String message);
201
public UnableToCreateProfileException(Throwable cause);
202
}
203
204
// Extension interface
205
public interface Extension {
206
void writeTo(File parentDirectory);
207
}
208
```