Chrome DevTools Protocol (CDP) bindings for Selenium WebDriver targeting Chromium version 85
npx @tessl/cli install tessl/maven-org-seleniumhq-selenium--selenium-devtools-v85@4.29.00
# Selenium DevTools v85
1
2
Selenium DevTools v85 provides Java bindings for the Chrome DevTools Protocol (CDP) targeting Chromium version 85. This package contains the version-specific implementation classes that are automatically discovered and used by the Selenium DevTools framework. While users typically interact with the high-level DevTools API, this package provides the underlying v85-specific functionality for network monitoring, JavaScript execution, console events, logging, and target management.
3
4
## Package Information
5
6
- **Package Name**: selenium-devtools-v85
7
- **Package Type**: maven
8
- **Language**: Java
9
- **Installation**: Add to your Maven dependencies:
10
11
```xml
12
<dependency>
13
<groupId>org.seleniumhq.selenium</groupId>
14
<artifactId>selenium-devtools-v85</artifactId>
15
<version>4.29.0</version>
16
</dependency>
17
```
18
19
## Core Imports
20
21
```java
22
import org.openqa.selenium.devtools.v85.V85Domains;
23
import org.openqa.selenium.devtools.v85.V85CdpInfo;
24
import org.openqa.selenium.devtools.DevTools;
25
```
26
27
## Basic Usage
28
29
**High-Level API (Recommended):**
30
Users typically access DevTools functionality through the high-level API, which automatically uses this v85 implementation when connected to a compatible Chromium version:
31
32
```java
33
import org.openqa.selenium.chrome.ChromeDriver;
34
import org.openqa.selenium.devtools.DevTools;
35
import org.openqa.selenium.devtools.HasDevTools;
36
import org.openqa.selenium.devtools.events.ConsoleEvent;
37
38
// Create Chrome driver with DevTools
39
ChromeDriver driver = new ChromeDriver();
40
DevTools devTools = ((HasDevTools) driver).getDevTools();
41
devTools.createSession();
42
43
// Use high-level API - automatically uses v85 implementation
44
devTools.getDomains().events().addConsoleListener(event -> {
45
System.out.println("Console: " + event.getType() + " - " + event.getMessages());
46
});
47
48
// Network interception (high-level API)
49
devTools.getDomains().network().interceptTrafficWith(filter -> {
50
// Process HTTP requests and responses
51
return req -> {
52
// Process request and return response or NetworkInterceptor.PROCEED_WITH_REQUEST
53
return org.openqa.selenium.devtools.NetworkInterceptor.PROCEED_WITH_REQUEST;
54
};
55
});
56
57
// Close session when done
58
devTools.close();
59
driver.quit();
60
```
61
62
**Direct v85 API (Internal):**
63
This package also provides direct access to v85-specific classes for advanced use cases:
64
65
```java
66
import org.openqa.selenium.devtools.v85.V85Domains;
67
import org.openqa.selenium.devtools.v85.runtime.Runtime;
68
import org.openqa.selenium.devtools.v85.runtime.model.ConsoleAPICalled;
69
import java.util.Optional;
70
71
// Access v85 implementation directly
72
V85Domains domains = new V85Domains(devTools);
73
74
// Enable runtime and monitor console events
75
devTools.send(Runtime.enable());
76
devTools.addListener(Runtime.consoleAPICalled(), event -> {
77
System.out.println("Console: " + event.getType() + " - " + event.getArgs());
78
});
79
```
80
81
## Architecture
82
83
The DevTools v85 package is built around several key components:
84
85
- **Service Discovery**: V85CdpInfo is auto-discovered via @AutoService annotation and registered for Chromium v85
86
- **V85Domains**: Central entry point providing access to all CDP domains for v85
87
- **Domain Handlers**: Specialized v85 implementations for each CDP domain (Network, JavaScript, Events, etc.)
88
- **Generated CDP Classes**: Auto-generated Java classes from CDP protocol definitions for v85
89
- **Event System**: Asynchronous event handling for real-time browser notifications
90
- **Command/Response Pattern**: Type-safe CDP command execution with structured responses
91
92
**Service Discovery Pattern:**
93
This package uses Google's AutoService to automatically register the V85CdpInfo class, which tells the DevTools framework that this implementation supports Chromium version 85. When a DevTools session connects to a compatible browser, this implementation is automatically selected and used.
94
95
## Capabilities
96
97
### Network Interception
98
99
Network monitoring and HTTP request/response interception capabilities. Monitor network traffic, modify requests/responses, handle authentication challenges, and control caching behavior.
100
101
```java { .api }
102
public class V85Network extends Network<AuthRequired, RequestPaused> {
103
public V85Network(DevTools devTools);
104
105
// Public methods accessible to the DevTools framework
106
public Event<RequestPaused> requestPausedEvent();
107
public Either<HttpRequest, HttpResponse> createSeMessages(RequestPaused pausedReq);
108
109
// Note: Most functionality is accessed through high-level DevTools API:
110
// devTools.getDomains().network().interceptTraffic(...)
111
// devTools.getDomains().network().disable()
112
}
113
```
114
115
[Network Interception](./network.md)
116
117
### JavaScript Execution
118
119
JavaScript execution in different browser contexts with binding support. Execute scripts, create persistent bindings between browser and Java, and inject scripts on page load.
120
121
```java { .api }
122
public class V85Javascript extends Javascript<ScriptIdentifier, BindingCalled> {
123
public V85Javascript(DevTools devtools);
124
125
// Note: JavaScript functionality is typically accessed through:
126
// devTools.getDomains().javascript().pin("script")
127
// devTools.getDomains().javascript().addJsBinding("name", callback)
128
// Or direct CDP commands: Runtime.addBinding(), Runtime.evaluate()
129
}
130
```
131
132
[JavaScript Execution](./javascript.md)
133
134
### Console and Runtime Events
135
136
Runtime event monitoring including console API calls, JavaScript exceptions, and error handling. Capture browser console output and JavaScript runtime errors in real-time.
137
138
```java { .api }
139
public class V85Events extends Events<ConsoleAPICalled, ExceptionThrown> {
140
public V85Events(DevTools devtools);
141
142
// Note: Console events are typically accessed through:
143
// devTools.getDomains().events().addConsoleListener(event -> {...})
144
// devTools.getDomains().events().addJavascriptExceptionListener(exception -> {...})
145
}
146
```
147
148
[Console and Events](./events.md)
149
150
### Browser Logging
151
152
Browser log capture and management. Access browser logs with different severity levels and timestamps for debugging and monitoring.
153
154
```java { .api }
155
public class V85Log implements org.openqa.selenium.devtools.idealized.log.Log {
156
public Command<Void> enable();
157
public Command<Void> clear();
158
public Event<LogEntry> entryAdded();
159
}
160
```
161
162
[Browser Logging](./logging.md)
163
164
### Target Management
165
166
Browser target (tab/window) management and session handling. Create, attach to, and manage browser contexts and targets for multi-tab automation.
167
168
```java { .api }
169
public class V85Target implements org.openqa.selenium.devtools.idealized.target.Target {
170
public Command<List<TargetInfo>> getTargets();
171
public Command<SessionID> attachToTarget(TargetID targetId);
172
public Command<Void> detachFromTarget(Optional<SessionID> sessionId, Optional<TargetID> targetId);
173
public Command<Void> setAutoAttach();
174
public Event<TargetID> detached();
175
}
176
```
177
178
[Target Management](./target.md)
179
180
## Core Types
181
182
```java { .api }
183
/**
184
* Main CDP information and version handler
185
*/
186
public class V85CdpInfo extends CdpInfo {
187
public V85CdpInfo();
188
}
189
190
/**
191
* Central domain access point
192
*/
193
public class V85Domains implements Domains {
194
public V85Domains(DevTools devtools);
195
public Events<?, ?> events();
196
public Javascript<?, ?> javascript();
197
public Network<?, ?> network();
198
public Target target();
199
public Log log();
200
}
201
202
/**
203
* User agent configuration for network requests (nested class in Network)
204
*/
205
public static class Network.UserAgent {
206
public UserAgent(String userAgent);
207
public UserAgent acceptLanguage(String acceptLanguage);
208
public UserAgent platform(String platform);
209
public String userAgent();
210
public Optional<String> acceptLanguage();
211
public Optional<String> platform();
212
}
213
214
/**
215
* Username and password credentials
216
*/
217
public class UsernameAndPassword {
218
public String username();
219
public String password();
220
}
221
```