Chrome DevTools Protocol (CDP) client library for Chrome version 105, providing Java bindings for browser automation and debugging capabilities
npx @tessl/cli install tessl/maven-org-seleniumhq-selenium--selenium-devtools-v105@4.6.00
# Selenium DevTools v105
1
2
Selenium DevTools v105 provides Java bindings for the Chrome DevTools Protocol (CDP) version 105, enabling programmatic interaction with Chrome browsers for advanced automation, debugging, and monitoring capabilities. This library offers both high-level wrapper classes and direct access to auto-generated CDP domain APIs, making it essential for advanced browser automation scenarios beyond standard WebDriver capabilities.
3
4
## Package Information
5
6
- **Package Name**: selenium-devtools-v105
7
- **Package Type**: maven
8
- **Language**: Java
9
- **Installation**:
10
```xml
11
<dependency>
12
<groupId>org.seleniumhq.selenium</groupId>
13
<artifactId>selenium-devtools-v105</artifactId>
14
<version>4.6.0</version>
15
</dependency>
16
```
17
18
## Core Imports
19
20
```java
21
import org.openqa.selenium.devtools.v105.V105Domains;
22
import org.openqa.selenium.devtools.v105.V105CdpInfo;
23
import org.openqa.selenium.devtools.DevTools;
24
import org.openqa.selenium.chrome.ChromeDriver;
25
import org.openqa.selenium.devtools.HasDevTools;
26
```
27
28
## Basic Usage
29
30
```java
31
// Initialize Chrome driver with DevTools
32
ChromeDriver driver = new ChromeDriver();
33
DevTools devTools = driver.getDevTools();
34
devTools.createSession();
35
36
// Access v105 domains
37
V105Domains domains = new V105Domains(devTools);
38
39
// Enable network domain for monitoring
40
devTools.send(org.openqa.selenium.devtools.v105.network.Network.enable());
41
42
// Set up authentication handling using network domain
43
domains.network().authRequiredEvent().addListener(authRequired -> {
44
if (domains.network().getUriFrom(authRequired).contains("secure.example.com")) {
45
devTools.send(domains.network().continueWithAuth(authRequired,
46
new UsernameAndPassword("user", "pass")));
47
}
48
});
49
50
// Listen for console events
51
domains.events().consoleEvent().addListener(consoleEvent -> {
52
org.openqa.selenium.devtools.events.ConsoleEvent event =
53
domains.events().toConsoleEvent(consoleEvent);
54
System.out.println("Console: " + event.getMessages());
55
});
56
57
// Add JavaScript binding for communication
58
devTools.send(domains.javascript().doAddJsBinding("javaCallback"));
59
domains.javascript().bindingCalledEvent().addListener(bindingCalled -> {
60
String payload = domains.javascript().extractPayload(bindingCalled);
61
System.out.println("JavaScript called: " + payload);
62
});
63
64
// Use direct CDP for JavaScript evaluation
65
devTools.send(org.openqa.selenium.devtools.v105.runtime.Runtime.evaluate("return document.title"));
66
67
// Clean up
68
devTools.send(org.openqa.selenium.devtools.v105.network.Network.disable());
69
domains.javascript().disable();
70
driver.quit();
71
```
72
73
## Architecture
74
75
Selenium DevTools v105 is built around several key components:
76
77
- **V105Domains**: Main entry point providing access to high-level idealized interfaces
78
- **Domain Implementations**: High-level wrappers (V105Network, V105Events, etc.) that provide Selenium-friendly APIs
79
- **Generated CDP Classes**: Auto-generated classes from Chrome DevTools Protocol specifications for direct protocol access
80
- **Version Compatibility**: Specifically designed for Chrome version 105 with exact CDP compatibility
81
- **Idealized Interfaces**: Abstract interfaces that allow version-agnostic programming across different Chrome versions
82
83
## Capabilities
84
85
### Network Interception and Monitoring
86
87
Advanced network interception capabilities including request/response modification, authentication handling, and traffic monitoring. Essential for testing scenarios requiring network manipulation.
88
89
```java { .api }
90
public class V105Network extends Network<AuthRequired, RequestPaused> {
91
public V105Network(DevTools devTools);
92
93
// Key network operations (inherited from Network base class)
94
protected Command<Void> setUserAgentOverride(UserAgent userAgent);
95
protected Command<Void> enableNetworkCaching();
96
protected Command<Void> disableNetworkCaching();
97
}
98
```
99
100
[Network Operations](./network.md)
101
102
### Event Handling and Console Monitoring
103
104
Runtime event handling for console messages, JavaScript exceptions, and other browser events. Provides unified access to Chrome's runtime events with proper type conversion.
105
106
```java { .api }
107
public class V105Events extends Events<ConsoleAPICalled, ExceptionThrown> {
108
public V105Events(DevTools devtools);
109
110
// Event subscription methods (inherited from Events base class)
111
protected Event<ConsoleAPICalled> consoleEvent();
112
protected Event<ExceptionThrown> exceptionThrownEvent();
113
114
// Event conversion methods
115
protected ConsoleEvent toConsoleEvent(ConsoleAPICalled event);
116
protected JavascriptException toJsException(ExceptionThrown event);
117
}
118
```
119
120
[Event Handling](./events.md)
121
122
### JavaScript Execution and Bindings
123
124
JavaScript evaluation capabilities with support for bindings, script injection, and runtime interaction. Enables advanced JavaScript automation beyond standard WebDriver execute_script.
125
126
```java { .api }
127
public class V105Javascript extends Javascript<ScriptIdentifier, BindingCalled> {
128
public V105Javascript(DevTools devtools);
129
130
// JavaScript operations (inherited from Javascript base class)
131
public void disable();
132
public ScriptId pin(String exposeScriptAs, String script);
133
134
// Protected methods for binding management
135
protected Command<Void> doAddJsBinding(String scriptName);
136
protected Command<Void> doRemoveJsBinding(String scriptName);
137
138
// Event handling
139
protected Event<BindingCalled> bindingCalledEvent();
140
protected String extractPayload(BindingCalled event);
141
}
142
```
143
144
[JavaScript Operations](./javascript.md)
145
146
### Browser Logging Access
147
148
Access to browser logs including console logs, network logs, and other browser-generated log messages. Provides structured access to Chrome's logging system.
149
150
```java { .api }
151
public class V105Log implements org.openqa.selenium.devtools.idealized.log.Log {
152
public V105Log();
153
154
public Command<Void> enable();
155
public Command<Void> clear();
156
public Event<org.openqa.selenium.devtools.idealized.log.model.LogEntry> entryAdded();
157
}
158
```
159
160
[Logging System](./logging.md)
161
162
### Target Management
163
164
Target management for handling browser tabs, web workers, iframes, and other browsing contexts. Essential for multi-context automation scenarios.
165
166
```java { .api }
167
public class V105Target implements org.openqa.selenium.devtools.idealized.target.Target {
168
public V105Target();
169
170
public Command<List<org.openqa.selenium.devtools.idealized.target.model.TargetInfo>> getTargets();
171
public Command<org.openqa.selenium.devtools.idealized.target.model.SessionID> attachToTarget(
172
org.openqa.selenium.devtools.idealized.target.model.TargetID targetId);
173
public Command<Void> detachFromTarget(
174
Optional<org.openqa.selenium.devtools.idealized.target.model.SessionID> sessionId,
175
Optional<org.openqa.selenium.devtools.idealized.target.model.TargetID> targetId);
176
public Command<Void> setAutoAttach();
177
public Event<org.openqa.selenium.devtools.idealized.target.model.TargetID> detached();
178
}
179
```
180
181
[Target Management](./targets.md)
182
183
### Direct CDP Domain Access
184
185
Direct access to all generated Chrome DevTools Protocol domains for advanced use cases requiring protocol-level control. Includes 41+ domains with full type-safe Java bindings.
186
187
```java { .api }
188
// Runtime domain for JavaScript execution
189
import org.openqa.selenium.devtools.v105.runtime.Runtime;
190
191
// Network domain for network control
192
import org.openqa.selenium.devtools.v105.network.Network;
193
194
// Page domain for page lifecycle
195
import org.openqa.selenium.devtools.v105.page.Page;
196
```
197
198
[CDP Domains](./cdp-domains.md)
199
200
## Types
201
202
### Core Domain Types
203
204
```java { .api }
205
// Main domains container
206
public class V105Domains implements Domains {
207
public V105Domains(DevTools devtools);
208
209
Events<?, ?> events();
210
Javascript<?, ?> javascript();
211
Network<?, ?> network();
212
Target target();
213
Log log();
214
}
215
216
// CDP version info
217
public class V105CdpInfo extends CdpInfo {
218
public V105CdpInfo();
219
}
220
```
221
222
### Network Types
223
224
```java { .api }
225
// User agent configuration
226
public static class UserAgent {
227
String userAgent();
228
String acceptLanguage();
229
String platform();
230
}
231
232
// Authentication types
233
public class AuthRequired {
234
AuthChallenge getAuthChallenge();
235
RequestId getRequestId();
236
}
237
238
public class RequestPaused {
239
RequestId getRequestId();
240
Request getRequest();
241
Optional<Integer> getResponseStatusCode();
242
}
243
```
244
245
### Event Types
246
247
```java { .api }
248
// Console event data
249
public class ConsoleEvent {
250
String getType();
251
Instant getTimestamp();
252
List<Object> getMessages();
253
}
254
255
// JavaScript exception data
256
public class JavascriptException extends RuntimeException {
257
JavascriptException(String message);
258
StackTraceElement[] getStackTrace();
259
}
260
```
261
262
### JavaScript Types
263
264
```java { .api }
265
// Script identifier for injected scripts
266
public class ScriptIdentifier {
267
String toString();
268
}
269
270
// Binding call event data
271
public class BindingCalled {
272
String getPayload();
273
String getName();
274
}
275
```
276
277
### Target Types
278
279
```java { .api }
280
// Target information
281
public class TargetInfo {
282
TargetID getTargetId();
283
String getType();
284
String getTitle();
285
String getUrl();
286
Boolean getAttached();
287
Optional<TargetID> getOpenerId();
288
}
289
290
// Target and session identifiers
291
public class TargetID {
292
TargetID(String id);
293
String toString();
294
}
295
296
public class SessionID {
297
SessionID(String id);
298
String toString();
299
}
300
```
301
302
### Log Types
303
304
```java { .api }
305
// Log entry data
306
public class LogEntry {
307
String getSource();
308
Level getLevel();
309
long getTimestamp();
310
String getText();
311
}
312
```