0
# Domain Management
1
2
Central access point for all Chrome DevTools Protocol domains, providing unified initialization and lifecycle management through the v115Domains class.
3
4
## Capabilities
5
6
### Domains Container
7
8
The main entry point for accessing all DevTools domains with proper initialization and dependency management.
9
10
```java { .api }
11
/**
12
* Main domains container providing access to all CDP domains
13
* Implements the idealized Domains interface for version independence
14
*/
15
public class v115Domains implements Domains {
16
/**
17
* Creates a new domains instance with DevTools connection
18
* @param devtools DevTools instance for CDP communication
19
* @throws org.openqa.selenium.internal.Require.Argument if devtools is null
20
*/
21
public v115Domains(DevTools devtools);
22
23
/**
24
* Returns the Events domain for console and runtime event handling
25
* @return Events domain instance for v115
26
*/
27
public Events<?, ?> events();
28
29
/**
30
* Returns the Javascript domain for script injection and bindings
31
* @return Javascript domain instance for v115
32
*/
33
public Javascript<?, ?> javascript();
34
35
/**
36
* Returns the Network domain for traffic interception and manipulation
37
* @return Network domain instance for v115
38
*/
39
public Network<?, ?> network();
40
41
/**
42
* Returns the Target domain for tab/window management
43
* @return Target domain instance for v115
44
*/
45
public Target target();
46
47
/**
48
* Returns the Log domain for browser console logging
49
* @return Log domain instance for v115
50
*/
51
public Log log();
52
}
53
```
54
55
**Usage Examples:**
56
57
```java
58
import org.openqa.selenium.chrome.ChromeDriver;
59
import org.openqa.selenium.devtools.DevTools;
60
import org.openqa.selenium.devtools.v115.v115Domains;
61
62
// Initialize WebDriver and DevTools
63
ChromeDriver driver = new ChromeDriver();
64
DevTools devTools = driver.getDevTools();
65
devTools.createSession();
66
67
// Create domains container
68
v115Domains domains = new v115Domains(devTools);
69
70
// Access individual domains
71
var events = domains.events();
72
var javascript = domains.javascript();
73
var network = domains.network();
74
var target = domains.target();
75
var log = domains.log();
76
77
// Use domains for automation
78
events.addConsoleListener(event ->
79
System.out.println("Console: " + event.getType()));
80
81
javascript.addJsBinding("myCallback");
82
network.setUserAgent("Custom Agent");
83
84
driver.quit();
85
```
86
87
### Service Provider Registration
88
89
Automatic registration of CDP version 115 support with Selenium's DevTools infrastructure.
90
91
```java { .api }
92
/**
93
* CDP version information service provider
94
* Automatically registered via @AutoService annotation
95
*/
96
@AutoService(CdpInfo.class)
97
public class v115CdpInfo extends CdpInfo {
98
/**
99
* Creates CDP info for version 115 with domains factory
100
* Registers version 115 and provides v115Domains constructor
101
*/
102
public v115CdpInfo();
103
}
104
```
105
106
**Usage Examples:**
107
108
```java
109
// Service is automatically registered - no manual setup required
110
// Selenium WebDriver automatically detects CDP v115 support
111
112
ChromeDriver driver = new ChromeDriver();
113
DevTools devTools = driver.getDevTools();
114
115
// DevTools automatically uses v115 implementation when available
116
devTools.createSession();
117
118
// Access CDP functionality through DevTools
119
devTools.send(org.openqa.selenium.devtools.v115.runtime.Runtime.enable());
120
```
121
122
## Domain Initialization Order
123
124
The v115Domains constructor initializes domains in a specific order to ensure proper dependency management:
125
126
1. **Events Domain** (`v115Events`) - Initialized first with DevTools connection
127
2. **Javascript Domain** (`v115Javascript`) - Initialized with DevTools connection
128
3. **Log Domain** (`v115Log`) - Initialized without dependencies
129
4. **Network Domain** (`v115Network`) - Initialized with DevTools connection
130
5. **Target Domain** (`v115Target`) - Initialized without dependencies
131
132
## Error Handling
133
134
### Required Parameter Validation
135
136
```java
137
// DevTools parameter is validated using Selenium's Require utility
138
public v115Domains(DevTools devtools) {
139
Require.nonNull("DevTools", devtools);
140
// ... initialization
141
}
142
```
143
144
### Domain Access
145
146
All domain accessor methods return non-null instances that are initialized during construction. No additional null checks are required when using the returned domain objects.
147
148
## Integration with Idealized APIs
149
150
The v115Domains class implements the idealized `Domains` interface, providing version-independent access to DevTools functionality:
151
152
```java
153
// Can be used polymorphically with other CDP versions
154
Domains domains = new v115Domains(devTools);
155
156
// Standard interface methods work across versions
157
domains.events().addConsoleListener(listener);
158
domains.javascript().addJsBinding("binding");
159
domains.network().setUserAgent("agent");
160
```
161
162
This design allows applications to work with multiple CDP versions without code changes, as long as they use the idealized interface methods.