Chrome DevTools Protocol version 99 support library for Selenium WebDriver Java bindings
npx @tessl/cli install tessl/maven-org-seleniumhq-selenium--selenium-devtools-v99@4.1.00
# Selenium DevTools v99
1
2
Selenium DevTools v99 provides comprehensive Chrome DevTools Protocol (CDP) version 99 support for Selenium WebDriver Java bindings. It enables low-level browser automation, debugging, and monitoring capabilities through direct access to Chrome's native debugging protocol.
3
4
## Package Information
5
6
- **Package Name**: selenium-devtools-v99
7
- **Package Type**: Maven
8
- **Language**: Java
9
- **Installation**: `org.seleniumhq.selenium:selenium-devtools-v99:4.1.4`
10
11
## Core Imports
12
13
```java
14
import org.openqa.selenium.devtools.v99.V99CdpInfo;
15
import org.openqa.selenium.devtools.v99.V99Domains;
16
import org.openqa.selenium.devtools.DevTools;
17
```
18
19
For direct protocol access:
20
21
```java
22
import org.openqa.selenium.devtools.v99.runtime.Runtime;
23
import org.openqa.selenium.devtools.v99.network.Network;
24
import org.openqa.selenium.devtools.v99.page.Page;
25
import org.openqa.selenium.devtools.v99.log.Log;
26
import org.openqa.selenium.devtools.v99.target.Target;
27
import org.openqa.selenium.devtools.v99.fetch.Fetch;
28
import java.util.function.Consumer;
29
```
30
31
## Basic Usage
32
33
```java
34
import org.openqa.selenium.WebDriver;
35
import org.openqa.selenium.chrome.ChromeDriver;
36
import org.openqa.selenium.devtools.DevTools;
37
import org.openqa.selenium.devtools.v99.V99Domains;
38
39
// Create WebDriver and access DevTools
40
WebDriver driver = new ChromeDriver();
41
DevTools devTools = ((ChromeDriver) driver).getDevTools();
42
devTools.createSession();
43
44
// Access v99 domains
45
V99Domains domains = new V99Domains(devTools);
46
47
// Enable network monitoring using public API
48
domains.network().setUserAgent("Custom User Agent for Testing");
49
50
// Listen for console events using public API
51
domains.events().addConsoleListener(consoleEvent -> {
52
System.out.println("Console: " + consoleEvent.getType() + " - " + consoleEvent.getMessages());
53
});
54
55
// Set up JavaScript binding using public API
56
domains.javascript().addJsBinding("myCallback");
57
domains.javascript().addBindingCalledListener(payload -> {
58
System.out.println("JavaScript binding called: " + payload);
59
});
60
```
61
62
## Architecture
63
64
Selenium DevTools v99 is built around several key architectural components:
65
66
- **CDP Version Support**: Specifically targets Chrome DevTools Protocol version 99
67
- **Domain-Based Organization**: Each CDP domain (Network, Runtime, Page, etc.) has dedicated classes
68
- **Command Pattern**: All operations use CDP commands sent through DevTools client
69
- **Event-Driven Model**: Browser events are handled through listener registration
70
- **Generated Protocol Classes**: Most protocol classes are generated from CDP specifications
71
- **Type Safety**: Strongly-typed Java interfaces for all CDP operations
72
73
The library provides two access levels:
74
- **High-level wrapper classes** (V99*) for common operations with simplified APIs
75
- **Generated protocol classes** for direct CDP access with full protocol fidelity
76
77
## Capabilities
78
79
### JavaScript Operations
80
81
JavaScript execution, debugging, and browser-side binding management for advanced automation scenarios.
82
83
```java { .api }
84
public class V99Javascript extends Javascript<ScriptIdentifier, BindingCalled> {
85
public V99Javascript(DevTools devtools);
86
87
// High-level public methods
88
public void addJsBinding(String scriptName);
89
public void removeJsBinding(String scriptName);
90
public void addBindingCalledListener(Consumer<String> listener);
91
public ScriptId pin(String exposeScriptAs, String script);
92
public void disable();
93
}
94
```
95
96
[JavaScript Operations](./javascript.md)
97
98
### Network Management
99
100
Network traffic monitoring, request interception, authentication handling, and response manipulation for comprehensive network control.
101
102
```java { .api }
103
public class V99Network extends Network<AuthRequired, RequestPaused> {
104
public V99Network(DevTools devTools);
105
106
// High-level public methods
107
public void setUserAgent(String userAgent);
108
public void setUserAgent(UserAgent userAgent);
109
public void addAuthHandler(Predicate<URI> whenThisMatches, Supplier<Credentials> useTheseCredentials);
110
public void resetNetworkFilter();
111
public void interceptTrafficWith(Filter filter);
112
public void prepareToInterceptTraffic();
113
public void disable();
114
}
115
```
116
117
[Network Management](./network.md)
118
119
### Event Handling
120
121
Browser event monitoring including console messages, JavaScript exceptions, and runtime events for debugging and monitoring.
122
123
```java { .api }
124
public class V99Events extends Events<ConsoleAPICalled, ExceptionThrown> {
125
public V99Events(DevTools devtools);
126
127
// High-level public methods
128
public void addConsoleListener(Consumer<ConsoleEvent> listener);
129
public void addJavascriptExceptionListener(Consumer<JavascriptException> listener);
130
public void disable();
131
}
132
```
133
134
[Event Handling](./events.md)
135
136
### Log Management
137
138
Browser console and log event collection with level filtering and timestamp handling for comprehensive logging support.
139
140
```java { .api }
141
public class V99Log implements org.openqa.selenium.devtools.idealized.log.Log {
142
public Command<Void> enable();
143
public Command<Void> clear();
144
public Event<LogEntry> entryAdded();
145
}
146
```
147
148
[Log Management](./logging.md)
149
150
### Target Management
151
152
Browser target (tab/window/iframe) management including attachment, detachment, and target enumeration for multi-context automation.
153
154
```java { .api }
155
public class V99Target implements org.openqa.selenium.devtools.idealized.target.Target {
156
public Command<Void> detachFromTarget(Optional<SessionID> sessionId, Optional<TargetID> targetId);
157
public Command<List<TargetInfo>> getTargets();
158
public Command<SessionID> attachToTarget(TargetID targetId);
159
public Command<Void> setAutoAttach();
160
public Event<TargetID> detached();
161
}
162
```
163
164
[Target Management](./targets.md)
165
166
## Core Types
167
168
### Domain Access
169
170
```java { .api }
171
public class V99Domains implements Domains {
172
public V99Domains(DevTools devtools);
173
174
public Events<?, ?> events();
175
public Javascript<?, ?> javascript();
176
public Network<?, ?> network();
177
public Target target();
178
public Log log();
179
}
180
```
181
182
### CDP Information
183
184
```java { .api }
185
@AutoService(CdpInfo.class)
186
public class V99CdpInfo extends CdpInfo {
187
public V99CdpInfo();
188
}
189
```
190
191
### Common Protocol Types
192
193
```java { .api }
194
// Session and target identifiers
195
public class SessionID {
196
public SessionID(String id);
197
public String toString();
198
}
199
200
public class TargetID {
201
public TargetID(String id);
202
public String toString();
203
}
204
205
// Network types
206
public class UserAgent {
207
public String userAgent();
208
public String acceptLanguage();
209
public String platform();
210
}
211
212
// Authentication credentials
213
public class UsernameAndPassword {
214
public String username();
215
public String password();
216
}
217
```
218
219
## Error Handling
220
221
The library integrates with Selenium's standard exception hierarchy:
222
223
- **DevToolsException**: Thrown for CDP communication errors
224
- **JavascriptException**: Thrown for JavaScript execution errors with stack traces
225
- **WebDriverException**: Base exception for WebDriver-related errors
226
227
Exception handling follows standard Java patterns with specific exceptions for different error conditions. Most operations are synchronous and throw exceptions immediately, while event handlers receive error information through event data structures.