0
# Selenium DevTools v102
1
2
Java bindings for Chrome DevTools Protocol (CDP) version 102, providing programmatic access to Chrome browser debugging and automation capabilities through the DevTools API. This package enables advanced browser automation scenarios beyond standard WebDriver capabilities, including network interception, JavaScript execution, console monitoring, and target management.
3
4
## Package Information
5
6
- **Package Name**: selenium-devtools-v102
7
- **Package Type**: Maven
8
- **Language**: Java
9
- **Installation**:
10
```xml
11
<dependency>
12
<groupId>org.seleniumhq.selenium</groupId>
13
<artifactId>selenium-devtools-v102</artifactId>
14
<version>4.4.0</version>
15
</dependency>
16
```
17
18
For Gradle:
19
```gradle
20
implementation 'org.seleniumhq.selenium:selenium-devtools-v102:4.4.0'
21
```
22
23
## Core Imports
24
25
```java
26
import org.openqa.selenium.devtools.v102.V102Domains;
27
import org.openqa.selenium.devtools.v102.V102CdpInfo;
28
import org.openqa.selenium.devtools.DevTools;
29
```
30
31
## Basic Usage
32
33
```java
34
import org.openqa.selenium.chrome.ChromeDriver;
35
import org.openqa.selenium.devtools.DevTools;
36
import org.openqa.selenium.devtools.v102.V102Domains;
37
38
// Create ChromeDriver and get DevTools connection
39
ChromeDriver driver = new ChromeDriver();
40
DevTools devTools = driver.getDevTools();
41
devTools.createSession();
42
43
// Create V102 domains instance
44
V102Domains domains = new V102Domains(devTools);
45
46
// Enable different domains as needed
47
domains.network().enableNetworkCaching();
48
domains.events().enable();
49
domains.javascript().enable();
50
51
// Use the domains for various operations
52
// ... perform DevTools operations ...
53
54
// Cleanup
55
domains.disableAll();
56
driver.quit();
57
```
58
59
## Architecture
60
61
The selenium-devtools-v102 package is built around several key components:
62
63
- **V102Domains**: Main entry point providing access to all CDP domain implementations
64
- **Domain Wrappers**: High-level Java interfaces (V102Network, V102Events, etc.) that wrap low-level CDP protocol operations
65
- **CDP Info Provider**: Version-specific information and factory for creating domain instances
66
- **Generated Protocol Classes**: Auto-generated Java classes from Chrome DevTools Protocol definitions (runtime-generated)
67
- **Idealized Interfaces**: Abstract interfaces providing version-agnostic API surface
68
69
This design enables type-safe interaction with Chrome's debugging capabilities while abstracting CDP version-specific details.
70
71
## Capabilities
72
73
### Domain Management
74
75
Core functionality for managing CDP domains and creating the main entry point for all DevTools operations.
76
77
```java { .api }
78
/**
79
* Main entry point providing access to all CDP domain implementations
80
*/
81
public class V102Domains implements Domains {
82
public V102Domains(DevTools devtools);
83
public Events<?, ?> events();
84
public Javascript<?, ?> javascript();
85
public Network<?, ?> network();
86
public Target target();
87
public Log log();
88
public void disableAll();
89
}
90
91
/**
92
* CDP version information provider for v102
93
*/
94
public class V102CdpInfo extends CdpInfo {
95
public V102CdpInfo();
96
}
97
```
98
99
[Domain Management](./domain-management.md)
100
101
### Runtime Events and Console Handling
102
103
Handles runtime events like console API calls, JavaScript exceptions, and provides conversion utilities for Selenium's event system.
104
105
```java { .api }
106
public class V102Events extends Events<ConsoleAPICalled, ExceptionThrown> {
107
public V102Events(DevTools devtools);
108
protected Command<Void> enableRuntime();
109
protected Command<Void> disableRuntime();
110
protected Event<ConsoleAPICalled> consoleEvent();
111
protected Event<ExceptionThrown> exceptionThrownEvent();
112
}
113
```
114
115
[Runtime Events](./runtime-events.md)
116
117
### JavaScript Execution and Binding
118
119
Manages JavaScript execution, binding operations, and script injection for new documents.
120
121
```java { .api }
122
public class V102Javascript extends Javascript<ScriptIdentifier, BindingCalled> {
123
public V102Javascript(DevTools devtools);
124
protected Command<Void> enableRuntime();
125
protected Command<Void> enablePage();
126
protected Command<Void> doAddJsBinding(String scriptName);
127
protected Command<ScriptIdentifier> addScriptToEvaluateOnNewDocument(String script);
128
}
129
```
130
131
[JavaScript Execution](./javascript-execution.md)
132
133
### Network Operations and Interception
134
135
Handles network operations, request/response interception, authentication, and user agent management.
136
137
```java { .api }
138
public class V102Network extends Network<AuthRequired, RequestPaused> {
139
public V102Network(DevTools devTools);
140
protected Command<Void> setUserAgentOverride(UserAgent userAgent);
141
protected Command<Void> enableNetworkCaching();
142
protected Command<Void> enableFetchForAllPatterns();
143
protected Event<AuthRequired> authRequiredEvent();
144
protected Event<RequestPaused> requestPausedEvent();
145
}
146
```
147
148
[Network Operations](./network-operations.md)
149
150
### Console Log Management
151
152
Manages console log operations, log entries, and provides conversion between CDP log formats and Selenium's logging system.
153
154
```java { .api }
155
public class V102Log implements org.openqa.selenium.devtools.idealized.log.Log {
156
public Command<Void> enable();
157
public Command<Void> clear();
158
public Event<org.openqa.selenium.devtools.idealized.log.model.LogEntry> entryAdded();
159
}
160
```
161
162
[Console Logging](./console-logging.md)
163
164
### Target Management
165
166
Manages browser targets (tabs, windows, workers), attachment/detachment operations, and target information retrieval.
167
168
```java { .api }
169
public class V102Target implements org.openqa.selenium.devtools.idealized.target.Target {
170
public Command<Void> detachFromTarget(Optional<SessionID> sessionId, Optional<TargetID> targetId);
171
public Command<List<org.openqa.selenium.devtools.idealized.target.model.TargetInfo>> getTargets();
172
public Command<SessionID> attachToTarget(TargetID targetId);
173
public Command<Void> setAutoAttach();
174
}
175
```
176
177
[Target Management](./target-management.md)
178
179
## Types
180
181
Core types used across the API:
182
183
```java { .api }
184
// DevTools connection and command types
185
class DevTools { ... }
186
class Command<T> { ... }
187
class Event<T> { ... }
188
189
// User agent configuration
190
class UserAgent {
191
String userAgent();
192
String acceptLanguage();
193
String platform();
194
}
195
196
// Authentication credentials
197
class UsernameAndPassword {
198
String username();
199
String password();
200
}
201
202
// HTTP request/response types
203
class HttpRequest { ... }
204
class HttpResponse { ... }
205
206
// Either type for handling different response types
207
class Either<L, R> { ... }
208
209
// Target and session identifiers
210
class TargetID {
211
TargetID(String id);
212
String toString();
213
}
214
215
class SessionID {
216
SessionID(String id);
217
String toString();
218
}
219
```