0
# Selenium DevTools v115
1
2
Selenium DevTools v115 provides Java bindings for Chrome DevTools Protocol version 115, enabling programmatic access to Chrome browser debugging capabilities within Selenium WebDriver. It offers automated code generation from CDP protocol specifications to create type-safe Java APIs for browser automation, network monitoring, JavaScript execution, logging, and event handling.
3
4
## Package Information
5
6
- **Package Name**: selenium-devtools-v115
7
- **Package Type**: Maven
8
- **Language**: Java
9
- **Installation**:
10
```xml
11
<dependency>
12
<groupId>org.seleniumhq.selenium</groupId>
13
<artifactId>selenium-devtools-v115</artifactId>
14
<version>4.13.0</version>
15
</dependency>
16
```
17
18
## Core Imports
19
20
```java
21
import org.openqa.selenium.devtools.v115.v115Domains;
22
import org.openqa.selenium.devtools.DevTools;
23
```
24
25
Common for working with specific domains:
26
27
```java
28
import org.openqa.selenium.devtools.v115.v115Events;
29
import org.openqa.selenium.devtools.v115.v115Javascript;
30
import org.openqa.selenium.devtools.v115.v115Network;
31
import org.openqa.selenium.devtools.v115.v115Target;
32
import org.openqa.selenium.devtools.v115.v115Log;
33
```
34
35
## Basic Usage
36
37
```java
38
import org.openqa.selenium.chrome.ChromeDriver;
39
import org.openqa.selenium.devtools.DevTools;
40
import org.openqa.selenium.devtools.v115.v115Domains;
41
42
// Initialize WebDriver with DevTools support
43
ChromeDriver driver = new ChromeDriver();
44
DevTools devTools = driver.getDevTools();
45
devTools.createSession();
46
47
// Create domains instance
48
v115Domains domains = new v115Domains(devTools);
49
50
// Listen to console events
51
domains.events().addConsoleListener(event -> {
52
System.out.println("Console: " + event.getType() + " - " + event.getMessages());
53
});
54
55
// Add JavaScript binding
56
domains.javascript().addJsBinding("myCallback");
57
58
// Set user agent
59
domains.network().setUserAgent("Custom User Agent v1.0");
60
61
// Navigate and interact
62
driver.get("https://example.com");
63
64
driver.quit();
65
```
66
67
## Architecture
68
69
Selenium DevTools v115 is built around several key architectural layers:
70
71
- **Idealized Interface Layer**: Version-independent abstractions (Domains, Events, Javascript, Network, Target, Log) that provide a stable API across different CDP versions
72
- **v115 Implementation Classes**: Version-specific implementations (v115Domains, v115Events, etc.) that adapt CDP v115 to the idealized interfaces
73
- **Generated CDP Domain Classes**: Auto-generated classes from Chrome DevTools Protocol definitions covering 16+ domains (runtime, page, network, fetch, etc.)
74
- **Service Registration**: Automatic CDP version detection and registration via `v115CdpInfo` service provider
75
76
This layered architecture allows developers to use either high-level idealized APIs for common use cases or drop down to low-level CDP commands for advanced scenarios.
77
78
## Capabilities
79
80
### Domain Management
81
82
Central access point for all Chrome DevTools Protocol domains, providing unified initialization and lifecycle management.
83
84
```java { .api }
85
public class v115Domains implements Domains {
86
public v115Domains(DevTools devtools);
87
public Events<?, ?> events();
88
public Javascript<?, ?> javascript();
89
public Network<?, ?> network();
90
public Target target();
91
public Log log();
92
}
93
```
94
95
[Domain Management](./domain-management.md)
96
97
### Runtime Events & Exception Handling
98
99
Comprehensive event handling for console messages, JavaScript exceptions, and runtime events with idealized conversion and filtering capabilities.
100
101
```java { .api }
102
public class v115Events extends Events<ConsoleAPICalled, ExceptionThrown> {
103
public v115Events(DevTools devtools);
104
protected Command<Void> enableRuntime();
105
protected Command<Void> disableRuntime();
106
protected Event<ConsoleAPICalled> consoleEvent();
107
protected Event<ExceptionThrown> exceptionThrownEvent();
108
protected ConsoleEvent toConsoleEvent(ConsoleAPICalled event);
109
protected JavascriptException toJsException(ExceptionThrown event);
110
}
111
```
112
113
[Runtime Events](./runtime-events.md)
114
115
### JavaScript Injection & Bindings
116
117
JavaScript code injection, binding management, and script execution coordination with full lifecycle control and event monitoring.
118
119
```java { .api }
120
public class v115Javascript extends Javascript<ScriptIdentifier, BindingCalled> {
121
public v115Javascript(DevTools devtools);
122
protected Command<Void> enableRuntime();
123
protected Command<Void> disableRuntime();
124
protected Command<Void> doAddJsBinding(String scriptName);
125
protected Command<Void> doRemoveJsBinding(String scriptName);
126
protected Command<ScriptIdentifier> addScriptToEvaluateOnNewDocument(String script);
127
protected Command<Void> removeScriptToEvaluateOnNewDocument(ScriptIdentifier id);
128
protected Event<BindingCalled> bindingCalledEvent();
129
protected String extractPayload(BindingCalled event);
130
}
131
```
132
133
[JavaScript Integration](./javascript-integration.md)
134
135
### Network Interception & Authentication
136
137
Advanced network traffic interception, request/response manipulation, authentication handling, and user agent override capabilities.
138
139
```java { .api }
140
public class v115Network extends Network<AuthRequired, RequestPaused> {
141
public v115Network(DevTools devTools);
142
protected Command<Void> setUserAgentOverride(UserAgent userAgent);
143
protected Command<Void> enableNetworkCaching();
144
protected Command<Void> disableNetworkCaching();
145
protected Command<Void> enableFetchForAllPatterns();
146
protected Command<Void> disableFetch();
147
protected Event<AuthRequired> authRequiredEvent();
148
protected Command<Void> continueWithAuth(AuthRequired authRequired, UsernameAndPassword credentials);
149
protected Command<Void> cancelAuth(AuthRequired authRequired);
150
public Event<RequestPaused> requestPausedEvent();
151
public Either<HttpRequest, HttpResponse> createSeMessages(RequestPaused pausedReq);
152
protected Command<Void> continueRequest(RequestPaused pausedReq, HttpRequest req);
153
protected Command<Void> fulfillRequest(RequestPaused pausedReq, HttpResponse res);
154
}
155
```
156
157
[Network Operations](./network-operations.md)
158
159
### Target & Session Management
160
161
Browser target (tab/window) management, debugging session control, and multi-target coordination with attachment and detachment capabilities.
162
163
```java { .api }
164
public class v115Target implements Target {
165
public Command<Void> detachFromTarget(Optional<SessionID> sessionId, Optional<TargetID> targetId);
166
public Command<List<TargetInfo>> getTargets();
167
public Command<SessionID> attachToTarget(TargetID targetId);
168
public Command<Void> setAutoAttach();
169
public Event<TargetID> detached();
170
}
171
```
172
173
[Target Management](./target-management.md)
174
175
### Browser Logging
176
177
Browser console log collection, filtering, and event stream management with level conversion and timestamp handling.
178
179
```java { .api }
180
public class v115Log implements Log {
181
public Command<Void> enable();
182
public Command<Void> clear();
183
public Event<LogEntry> entryAdded();
184
}
185
```
186
187
[Logging Operations](./logging-operations.md)
188
189
## Core Types
190
191
```java { .api }
192
// Service Provider Registration
193
@AutoService(CdpInfo.class)
194
public class v115CdpInfo extends CdpInfo {
195
public v115CdpInfo();
196
}
197
198
// Idealized Model Types
199
public class ConsoleEvent {
200
public String getType();
201
public Instant getTimestamp();
202
public List<Object> getArgs();
203
public List<String> getMessages();
204
}
205
206
public class ScriptId {
207
// Opaque wrapper for script identifiers
208
}
209
210
public class UserAgent {
211
public String userAgent();
212
public Optional<String> acceptLanguage();
213
public Optional<String> platform();
214
}
215
216
// Target Model Types
217
public class TargetInfo {
218
public TargetID getTargetId();
219
public String getType();
220
public String getTitle();
221
public String getUrl();
222
public Boolean getAttached();
223
public Optional<TargetID> getOpenerId();
224
public Optional<BrowserContextID> getBrowserContextId();
225
}
226
227
public class SessionID {
228
public String toString();
229
}
230
231
public class TargetID {
232
public String toString();
233
}
234
235
// Log Model Types
236
public class LogEntry {
237
public String getKind();
238
public org.openqa.selenium.logging.LogEntry getEntry();
239
}
240
241
// Runtime Model Types
242
public class RemoteObject {
243
public String getType();
244
public Object getValue();
245
}
246
```