or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

tessl/maven-org-seleniumhq-selenium--selenium-devtools-v101

Java bindings for Chrome DevTools Protocol version 101, enabling browser automation and debugging capabilities through CDP integration

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
mavenpkg:maven/org.seleniumhq.selenium/selenium-devtools-v101@4.3.x

To install, run

npx @tessl/cli install tessl/maven-org-seleniumhq-selenium--selenium-devtools-v101@4.3.0

0

# Selenium DevTools v101

1

2

Selenium DevTools v101 provides Java language bindings for Chrome DevTools Protocol (CDP) version 101, enabling developers to interact with Chrome browser's debugging and automation APIs through Selenium WebDriver. This library offers comprehensive access to browser development tools including network monitoring, performance profiling, runtime evaluation, and advanced debugging capabilities.

3

4

## Package Information

5

6

- **Package Name**: selenium-devtools-v101

7

- **Package Type**: maven

8

- **Language**: Java

9

- **Group ID**: org.seleniumhq.selenium

10

- **Artifact ID**: selenium-devtools-v101

11

- **Version**: 4.3.0

12

- **Installation**: Add to Maven dependencies:

13

14

```xml

15

<dependency>

16

<groupId>org.seleniumhq.selenium</groupId>

17

<artifactId>selenium-devtools-v101</artifactId>

18

<version>4.3.0</version>

19

</dependency>

20

```

21

22

## Core Imports

23

24

```java

25

import org.openqa.selenium.devtools.v101.V101CdpInfo;

26

import org.openqa.selenium.devtools.v101.V101Domains;

27

import org.openqa.selenium.devtools.DevTools;

28

import org.openqa.selenium.devtools.idealized.Domains;

29

```

30

31

## Basic Usage

32

33

```java

34

import org.openqa.selenium.chrome.ChromeDriver;

35

import org.openqa.selenium.devtools.DevTools;

36

import org.openqa.selenium.devtools.v101.V101CdpInfo;

37

import org.openqa.selenium.devtools.idealized.Domains;

38

39

// Create Chrome driver and get DevTools

40

ChromeDriver driver = new ChromeDriver();

41

DevTools devTools = driver.getDevTools();

42

devTools.createSession();

43

44

// Get CDP v101 implementation

45

V101CdpInfo cdpInfo = new V101CdpInfo();

46

Domains domains = cdpInfo.getDomains(devTools);

47

48

// Listen to console events

49

domains.events().addConsoleListener(event -> {

50

System.out.println("Console " + event.getType() + ": " + event.getMessages());

51

});

52

53

// Set up network interception

54

domains.network().interceptTrafficWith(request -> {

55

// Modify or monitor network requests

56

return next -> next.execute(request);

57

});

58

59

// Add JavaScript bindings

60

domains.javascript().addJsBinding("myCustomFunction");

61

domains.javascript().addBindingCalledListener(payload -> {

62

System.out.println("JS binding called with: " + payload);

63

});

64

```

65

66

## Architecture

67

68

Selenium DevTools v101 is built around several key components:

69

70

- **V101CdpInfo**: Entry point providing version-specific CDP implementation

71

- **Domain System**: Organized access to CDP functionality through specialized domains

72

- **Event System**: Asynchronous event handling for browser notifications

73

- **Command Pattern**: Type-safe CDP command execution with structured responses

74

- **Generated Bindings**: Auto-generated CDP protocol classes from Chrome's specifications

75

76

## Capabilities

77

78

### Entry Point and Domain Management

79

80

Main entry point for accessing Chrome DevTools Protocol version 101 functionality and managing domain access.

81

82

```java { .api }

83

public class V101CdpInfo extends CdpInfo {

84

public V101CdpInfo();

85

public int getMajorVersion(); // Returns 101

86

public Domains getDomains(DevTools devTools);

87

}

88

89

public class V101Domains implements Domains {

90

public V101Domains(DevTools devtools);

91

public Events<?, ?> events();

92

public Javascript<?, ?> javascript();

93

public Network<?, ?> network();

94

public Target target();

95

public Log log();

96

public void disableAll();

97

}

98

```

99

100

[Entry Point and Domain Management](./entry-point.md)

101

102

### Console Events and JavaScript Exceptions

103

104

Real-time monitoring of browser console output and JavaScript runtime exceptions for debugging and monitoring purposes.

105

106

```java { .api }

107

public class V101Events extends Events<ConsoleAPICalled, ExceptionThrown> {

108

public V101Events(DevTools devtools);

109

public void addConsoleListener(Consumer<ConsoleEvent> listener);

110

public void addJavascriptExceptionListener(Consumer<JavascriptException> listener);

111

public void disable();

112

}

113

```

114

115

[Console Events and JavaScript Exceptions](./events.md)

116

117

### JavaScript Bindings and Script Evaluation

118

119

JavaScript execution control including custom bindings between browser JavaScript and Java code, and script injection capabilities.

120

121

```java { .api }

122

public class V101Javascript extends Javascript<ScriptIdentifier, BindingCalled> {

123

public V101Javascript(DevTools devtools);

124

public ScriptId pin(String exposeScriptAs, String script);

125

public void addBindingCalledListener(Consumer<String> listener);

126

public void addJsBinding(String scriptName);

127

public void removeJsBinding(String scriptName);

128

public void disable();

129

}

130

```

131

132

[JavaScript Bindings and Script Evaluation](./javascript.md)

133

134

### Network Interception and Authentication

135

136

Comprehensive network traffic control including request/response interception, authentication handling, and user agent manipulation.

137

138

```java { .api }

139

public class V101Network extends Network<AuthRequired, RequestPaused> {

140

public V101Network(DevTools devTools);

141

public void setUserAgent(String userAgent);

142

public void setUserAgent(UserAgent userAgent);

143

public void addAuthHandler(Predicate<URI> whenThisMatches, Supplier<Credentials> useTheseCredentials);

144

public void interceptTrafficWith(Filter filter);

145

public void prepareToInterceptTraffic();

146

public void resetNetworkFilter();

147

public void disable();

148

}

149

```

150

151

[Network Interception and Authentication](./network.md)

152

153

### Target Management

154

155

Browser target and session management for handling multiple tabs, windows, and browser contexts in complex automation scenarios.

156

157

```java { .api }

158

public class V101Target implements Target {

159

public V101Target();

160

public Command<Void> detachFromTarget(Optional<SessionID> sessionId, Optional<TargetID> targetId);

161

public Command<List<TargetInfo>> getTargets();

162

public Command<SessionID> attachToTarget(TargetID targetId);

163

public Command<Void> setAutoAttach();

164

public Event<TargetID> detached();

165

}

166

```

167

168

[Target Management](./target.md)

169

170

### Browser Logging

171

172

Browser-level logging functionality for capturing and managing browser console logs, network logs, and other browser-generated log messages.

173

174

```java { .api }

175

public class V101Log implements Log {

176

public V101Log();

177

public Command<Void> enable();

178

public Command<Void> clear();

179

public Event<LogEntry> entryAdded();

180

}

181

```

182

183

[Browser Logging](./logging.md)

184

185

## Core Framework Types

186

187

```java { .api }

188

// Main DevTools communication interface

189

public interface DevTools {

190

Domains getDomains();

191

<X> X send(Command<X> command);

192

<X> void addListener(Event<X> event, Consumer<X> handler);

193

void clearListeners();

194

void createSession();

195

void createSessionIfThereIsNotOne();

196

void disconnectSession();

197

void close();

198

}

199

200

// CDP command representation

201

public class Command<X> {

202

public String getMethod();

203

public Map<String, Object> getParams();

204

public boolean getSendsResponse();

205

public Command<X> doesNotSendResponse();

206

}

207

208

// CDP event representation

209

public class Event<X> {

210

public String getMethod();

211

}

212

213

// Console event data

214

public class ConsoleEvent {

215

public String getType();

216

public Instant getTimestamp();

217

public List<Object> getArgs();

218

public List<String> getMessages();

219

}

220

221

// JavaScript exception wrapper

222

public class JavascriptException extends RuntimeException {

223

public JavascriptException(String message);

224

}

225

226

// Script identifier wrapper

227

public class ScriptId {

228

public Object getActualId();

229

}

230

```

231

232

## Network Types

233

234

```java { .api }

235

// User agent configuration

236

public class UserAgent {

237

public UserAgent(String userAgent);

238

public UserAgent acceptLanguage(String acceptLanguage);

239

public UserAgent platform(String platform);

240

public String userAgent();

241

public Optional<String> acceptLanguage();

242

public Optional<String> platform();

243

}

244

245

// Authentication challenge data

246

public class AuthRequired {

247

public AuthChallenge getAuthChallenge();

248

public RequestId getRequestId();

249

}

250

251

// Intercepted request data

252

public class RequestPaused {

253

public RequestId getRequestId();

254

public Request getRequest();

255

public Optional<Integer> getResponseStatusCode();

256

public Optional<String> getResponseErrorReason();

257

public Optional<List<HeaderEntry>> getResponseHeaders();

258

}

259

260

// HTTP header entry

261

public class HeaderEntry {

262

public HeaderEntry(String name, String value);

263

public String getName();

264

public String getValue();

265

}

266

```

267

268

## Target Types

269

270

```java { .api }

271

// Target information

272

public class TargetInfo {

273

public TargetID getTargetId();

274

public String getType();

275

public String getTitle();

276

public String getUrl();

277

public Boolean getAttached();

278

public Optional<TargetID> getOpenerId();

279

public Optional<BrowserContextID> getBrowserContextId();

280

}

281

282

// ID wrapper types

283

public class TargetID {

284

public TargetID(String id);

285

public String toString();

286

}

287

288

public class SessionID {

289

public SessionID(String id);

290

public String toString();

291

}

292

293

public class BrowserContextID {

294

public BrowserContextID(String id);

295

public String toString();

296

}

297

```

298

299

## Log Types

300

301

```java { .api }

302

// Browser log entry

303

public class LogEntry {

304

public String getSource();

305

public LogEntry getLogEntry(); // Returns java.util.logging.LogEntry

306

}

307

```