0
# Selenium Chrome Driver
1
2
Selenium Chrome WebDriver implementation for automating Chrome browsers using the WebDriver protocol. Provides Java bindings for Chrome-specific capabilities, service management, and driver lifecycle operations with extensive configuration options for headless operation, extension management, and mobile device emulation.
3
4
## Package Information
5
6
- **Package Name**: selenium-chrome-driver
7
- **Package Type**: maven
8
- **Language**: Java
9
- **Installation**:
10
```xml
11
<dependency>
12
<groupId>org.seleniumhq.selenium</groupId>
13
<artifactId>selenium-chrome-driver</artifactId>
14
<version>3.141.59</version>
15
</dependency>
16
```
17
18
## Core Imports
19
20
```java
21
import org.openqa.selenium.chrome.ChromeDriver;
22
import org.openqa.selenium.chrome.ChromeOptions;
23
import org.openqa.selenium.chrome.ChromeDriverService;
24
```
25
26
## Basic Usage
27
28
```java
29
import org.openqa.selenium.chrome.ChromeDriver;
30
import org.openqa.selenium.chrome.ChromeOptions;
31
import org.openqa.selenium.WebDriver;
32
33
// Basic Chrome driver with default configuration
34
WebDriver driver = new ChromeDriver();
35
36
// With Chrome-specific options
37
ChromeOptions options = new ChromeOptions();
38
options.setHeadless(true);
39
options.addArguments("--no-sandbox", "--disable-dev-shm-usage");
40
options.addExtensions(new File("/path/to/extension.crx"));
41
42
WebDriver driver = new ChromeDriver(options);
43
44
// Navigate and interact
45
driver.get("https://example.com");
46
System.out.println(driver.getTitle());
47
driver.quit();
48
```
49
50
## Architecture
51
52
The Chrome Driver is built around several key components:
53
54
- **ChromeDriver**: Main WebDriver implementation extending RemoteWebDriver with Chrome-specific functionality
55
- **ChromeOptions**: Configuration class for Chrome browser settings, arguments, and extensions
56
- **ChromeDriverService**: Service management for ChromeDriver server lifecycle and configuration
57
- **ChromeDriverInfo**: Metadata provider for Chrome WebDriver capabilities and availability
58
- **Command Execution**: Chrome-specific WebDriver protocol commands and HTTP communication
59
60
## Capabilities
61
62
### WebDriver Implementation
63
64
Core Chrome WebDriver functionality providing browser automation, navigation, element interaction, and session management.
65
66
```java { .api }
67
public class ChromeDriver extends RemoteWebDriver
68
implements LocationContext, WebStorage, HasTouchScreen, NetworkConnection {
69
70
public ChromeDriver();
71
public ChromeDriver(ChromeDriverService service);
72
public ChromeDriver(ChromeOptions options);
73
public ChromeDriver(ChromeDriverService service, ChromeOptions options);
74
75
public void launchApp(String id);
76
public LocalStorage getLocalStorage();
77
public SessionStorage getSessionStorage();
78
public Location location();
79
public void setLocation(Location location);
80
public TouchScreen getTouch();
81
public ConnectionType getNetworkConnection();
82
public ConnectionType setNetworkConnection(ConnectionType type);
83
}
84
```
85
86
[WebDriver Implementation](./webdriver-implementation.md)
87
88
### Browser Configuration
89
90
Chrome-specific browser configuration including binary paths, command-line arguments, extensions, experimental options, and capability settings.
91
92
```java { .api }
93
public class ChromeOptions extends MutableCapabilities {
94
public static final String CAPABILITY = "goog:chromeOptions";
95
96
public ChromeOptions();
97
public ChromeOptions setBinary(String path);
98
public ChromeOptions addArguments(String... arguments);
99
public ChromeOptions addExtensions(File... paths);
100
public ChromeOptions setHeadless(boolean headless);
101
public ChromeOptions setExperimentalOption(String name, Object value);
102
public ChromeOptions setPageLoadStrategy(PageLoadStrategy strategy);
103
public ChromeOptions setAcceptInsecureCerts(boolean acceptInsecureCerts);
104
public ChromeOptions setProxy(Proxy proxy);
105
}
106
```
107
108
[Browser Configuration](./browser-configuration.md)
109
110
### Service Management
111
112
ChromeDriver server lifecycle management with port configuration, logging options, and process control for distributed testing scenarios.
113
114
```java { .api }
115
public class ChromeDriverService extends DriverService {
116
public static final String CHROME_DRIVER_EXE_PROPERTY = "webdriver.chrome.driver";
117
public static final String CHROME_DRIVER_LOG_PROPERTY = "webdriver.chrome.logfile";
118
119
public static ChromeDriverService createDefaultService();
120
121
public static class Builder extends DriverService.Builder<ChromeDriverService, ChromeDriverService.Builder> {
122
public Builder usingDriverExecutable(File file);
123
public Builder usingPort(int port);
124
public Builder usingAnyFreePort();
125
public Builder withLogFile(File logFile);
126
public Builder withEnvironment(Map<String, String> environment);
127
public Builder withVerbose(boolean verbose);
128
public Builder withSilent(boolean silent);
129
public Builder withWhitelistedIps(String whitelistedIps);
130
}
131
}
132
```
133
134
[Service Management](./service-management.md)
135
136
### Driver Information
137
138
WebDriver metadata and capability detection for automated driver selection and session creation in multi-browser testing environments.
139
140
```java { .api }
141
public class ChromeDriverInfo implements WebDriverInfo {
142
public String getDisplayName();
143
public Capabilities getCanonicalCapabilities();
144
public boolean isSupporting(Capabilities capabilities);
145
public boolean isAvailable();
146
public int getMaximumSimultaneousSessions();
147
public Optional<WebDriver> createDriver(Capabilities capabilities);
148
}
149
```
150
151
[Driver Information](./driver-information.md)
152
153
## Types
154
155
```java { .api }
156
// Core WebDriver interfaces implemented by ChromeDriver
157
interface WebDriver {
158
void get(String url);
159
String getTitle();
160
void quit();
161
// ... other WebDriver methods
162
}
163
164
interface LocationContext {
165
Location location();
166
void setLocation(Location location);
167
}
168
169
interface WebStorage {
170
LocalStorage getLocalStorage();
171
SessionStorage getSessionStorage();
172
}
173
174
interface HasTouchScreen {
175
TouchScreen getTouch();
176
}
177
178
interface NetworkConnection {
179
ConnectionType getNetworkConnection();
180
ConnectionType setNetworkConnection(ConnectionType type);
181
}
182
183
// Configuration types
184
enum PageLoadStrategy {
185
NORMAL, EAGER, NONE
186
}
187
188
enum UnexpectedAlertBehaviour {
189
ACCEPT, DISMISS, IGNORE
190
}
191
192
class Proxy {
193
// Proxy configuration methods
194
}
195
```