0
# Entry Point and Domain Management
1
2
The entry point and domain management components provide the main access points for Chrome DevTools Protocol version 101 functionality and organize CDP capabilities into logical domains.
3
4
## Capabilities
5
6
### V101CdpInfo
7
8
Entry point class that provides version-specific CDP implementation and domain access.
9
10
```java { .api }
11
/**
12
* Entry point for Chrome DevTools Protocol version 101
13
* Extends CdpInfo and is automatically discovered via Java ServiceLoader
14
*/
15
@AutoService(CdpInfo.class)
16
public class V101CdpInfo extends CdpInfo {
17
18
/**
19
* Creates a new V101CdpInfo instance configured for CDP version 101
20
*/
21
public V101CdpInfo();
22
}
23
```
24
25
**Inherited Methods from CdpInfo Base Class:**
26
27
```java { .api }
28
/**
29
* Get the major version number for this CDP implementation
30
* @return 101 for this implementation
31
*/
32
public int getMajorVersion();
33
34
/**
35
* Get the domains implementation for this CDP version
36
* @param devTools DevTools instance for communication
37
* @return V101Domains instance providing access to all CDP domains
38
*/
39
public Domains getDomains(DevTools devTools);
40
41
/**
42
* Compare this CDP version with another
43
* @param that Other CdpInfo to compare against
44
* @return Comparison result based on major version
45
*/
46
public int compareTo(CdpInfo that);
47
```
48
49
**Usage Example:**
50
51
```java
52
import org.openqa.selenium.devtools.v101.V101CdpInfo;
53
import org.openqa.selenium.devtools.DevTools;
54
import org.openqa.selenium.devtools.idealized.Domains;
55
56
// Create CDP info for version 101
57
V101CdpInfo cdpInfo = new V101CdpInfo();
58
59
// Verify version
60
System.out.println("CDP Version: " + cdpInfo.getMajorVersion()); // Prints: 101
61
62
// Get domains for a DevTools session
63
Domains domains = cdpInfo.getDomains(devTools);
64
```
65
66
### V101Domains
67
68
Central domain aggregator that provides organized access to all CDP functionality areas.
69
70
```java { .api }
71
/**
72
* Aggregates all available CDP domains for version 101
73
* Provides organized access to events, javascript, network, target, and log domains
74
*/
75
public class V101Domains implements Domains {
76
77
/**
78
* Creates a new domain aggregator instance
79
* @param devtools DevTools instance for CDP communication
80
* @throws NullPointerException if devtools is null
81
*/
82
public V101Domains(DevTools devtools);
83
84
/**
85
* Get the events domain for console and runtime event handling
86
* @return V101Events instance for managing console events and JavaScript exceptions
87
*/
88
@Override
89
public Events<?, ?> events();
90
91
/**
92
* Get the javascript domain for script evaluation and bindings
93
* @return V101Javascript instance for managing JavaScript bindings and script injection
94
*/
95
@Override
96
public Javascript<?, ?> javascript();
97
98
/**
99
* Get the network domain for traffic interception and authentication
100
* @return V101Network instance for network monitoring and manipulation
101
*/
102
@Override
103
public Network<?, ?> network();
104
105
/**
106
* Get the target domain for browser context and session management
107
* @return V101Target instance for managing browser targets and sessions
108
*/
109
@Override
110
public Target target();
111
112
/**
113
* Get the log domain for browser logging functionality
114
* @return V101Log instance for managing browser logs
115
*/
116
@Override
117
public Log log();
118
119
/**
120
* Disable all active domains to clean up resources
121
* Calls disable() on events, javascript, and network domains
122
*/
123
@Override
124
public void disableAll();
125
}
126
```
127
128
**Usage Example:**
129
130
```java
131
import org.openqa.selenium.devtools.v101.V101Domains;
132
import org.openqa.selenium.devtools.DevTools;
133
134
// Create domains aggregator
135
V101Domains domains = new V101Domains(devTools);
136
137
// Access individual domains
138
var events = domains.events();
139
var javascript = domains.javascript();
140
var network = domains.network();
141
var target = domains.target();
142
var log = domains.log();
143
144
// Enable console logging
145
events.addConsoleListener(event -> {
146
System.out.println("Console: " + event.getType() + " - " + event.getMessages());
147
});
148
149
// Add network interception
150
network.interceptTrafficWith(request -> {
151
System.out.println("Request: " + request.getUri());
152
return next -> next.execute(request);
153
});
154
155
// Clean up when done
156
domains.disableAll();
157
```
158
159
### Base CdpInfo Interface
160
161
```java { .api }
162
/**
163
* Base interface for CDP version information and domain access
164
* Implemented by version-specific classes like V101CdpInfo
165
*/
166
public abstract class CdpInfo implements Comparable<CdpInfo> {
167
168
/**
169
* Get the major version number for this CDP implementation
170
* @return Major version number (e.g., 101)
171
*/
172
public abstract int getMajorVersion();
173
174
/**
175
* Get the domains implementation for this CDP version
176
* @param devTools DevTools instance for communication
177
* @return Domains instance providing access to CDP functionality
178
*/
179
public abstract Domains getDomains(DevTools devTools);
180
181
/**
182
* Compare CDP versions by major version number
183
* @param that Other CdpInfo to compare against
184
* @return Negative, zero, or positive based on version comparison
185
*/
186
public int compareTo(CdpInfo that);
187
}
188
```
189
190
### Base Domains Interface
191
192
```java { .api }
193
/**
194
* Interface defining access to all CDP domain implementations
195
* Provides organized access to browser development tools functionality
196
*/
197
public interface Domains {
198
199
/**
200
* Get the events domain for runtime and console event handling
201
* @return Events implementation for this CDP version
202
*/
203
Events<?, ?> events();
204
205
/**
206
* Get the javascript domain for script evaluation and bindings
207
* @return Javascript implementation for this CDP version
208
*/
209
Javascript<?, ?> javascript();
210
211
/**
212
* Get the network domain for traffic monitoring and manipulation
213
* @return Network implementation for this CDP version
214
*/
215
Network<?, ?> network();
216
217
/**
218
* Get the target domain for browser context management
219
* @return Target implementation for this CDP version
220
*/
221
Target target();
222
223
/**
224
* Get the log domain for browser logging
225
* @return Log implementation for this CDP version
226
*/
227
Log log();
228
229
/**
230
* Disable all domains to clean up resources and event listeners
231
*/
232
void disableAll();
233
}
234
```
235
236
## Domain Lifecycle Management
237
238
**Initialization Pattern:**
239
240
```java
241
// Standard initialization sequence
242
ChromeDriver driver = new ChromeDriver();
243
DevTools devTools = driver.getDevTools();
244
devTools.createSession();
245
246
V101CdpInfo cdpInfo = new V101CdpInfo();
247
Domains domains = cdpInfo.getDomains(devTools);
248
249
// Use domains...
250
251
// Cleanup
252
domains.disableAll();
253
devTools.close();
254
driver.quit();
255
```
256
257
**Error Handling:**
258
259
```java
260
try {
261
V101Domains domains = new V101Domains(devTools);
262
// Use domains...
263
} catch (Exception e) {
264
// Handle CDP communication errors
265
System.err.println("CDP Error: " + e.getMessage());
266
} finally {
267
// Always clean up resources
268
if (domains != null) {
269
domains.disableAll();
270
}
271
}
272
```