Java bindings for Chrome DevTools Protocol version 102, providing programmatic access to Chrome browser debugging and automation capabilities
npx @tessl/cli install tessl/maven-org-seleniumhq-selenium--selenium-devtools-v102@4.4.0Java bindings for Chrome DevTools Protocol (CDP) version 102, providing programmatic access to Chrome browser debugging and automation capabilities through the DevTools API. This package enables advanced browser automation scenarios beyond standard WebDriver capabilities, including network interception, JavaScript execution, console monitoring, and target management.
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-devtools-v102</artifactId>
<version>4.4.0</version>
</dependency>For Gradle:
implementation 'org.seleniumhq.selenium:selenium-devtools-v102:4.4.0'import org.openqa.selenium.devtools.v102.V102Domains;
import org.openqa.selenium.devtools.v102.V102CdpInfo;
import org.openqa.selenium.devtools.DevTools;import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.devtools.DevTools;
import org.openqa.selenium.devtools.v102.V102Domains;
// Create ChromeDriver and get DevTools connection
ChromeDriver driver = new ChromeDriver();
DevTools devTools = driver.getDevTools();
devTools.createSession();
// Create V102 domains instance
V102Domains domains = new V102Domains(devTools);
// Enable different domains as needed
domains.network().enableNetworkCaching();
domains.events().enable();
domains.javascript().enable();
// Use the domains for various operations
// ... perform DevTools operations ...
// Cleanup
domains.disableAll();
driver.quit();The selenium-devtools-v102 package is built around several key components:
This design enables type-safe interaction with Chrome's debugging capabilities while abstracting CDP version-specific details.
Core functionality for managing CDP domains and creating the main entry point for all DevTools operations.
/**
* Main entry point providing access to all CDP domain implementations
*/
public class V102Domains implements Domains {
public V102Domains(DevTools devtools);
public Events<?, ?> events();
public Javascript<?, ?> javascript();
public Network<?, ?> network();
public Target target();
public Log log();
public void disableAll();
}
/**
* CDP version information provider for v102
*/
public class V102CdpInfo extends CdpInfo {
public V102CdpInfo();
}Handles runtime events like console API calls, JavaScript exceptions, and provides conversion utilities for Selenium's event system.
public class V102Events extends Events<ConsoleAPICalled, ExceptionThrown> {
public V102Events(DevTools devtools);
protected Command<Void> enableRuntime();
protected Command<Void> disableRuntime();
protected Event<ConsoleAPICalled> consoleEvent();
protected Event<ExceptionThrown> exceptionThrownEvent();
}Manages JavaScript execution, binding operations, and script injection for new documents.
public class V102Javascript extends Javascript<ScriptIdentifier, BindingCalled> {
public V102Javascript(DevTools devtools);
protected Command<Void> enableRuntime();
protected Command<Void> enablePage();
protected Command<Void> doAddJsBinding(String scriptName);
protected Command<ScriptIdentifier> addScriptToEvaluateOnNewDocument(String script);
}Handles network operations, request/response interception, authentication, and user agent management.
public class V102Network extends Network<AuthRequired, RequestPaused> {
public V102Network(DevTools devTools);
protected Command<Void> setUserAgentOverride(UserAgent userAgent);
protected Command<Void> enableNetworkCaching();
protected Command<Void> enableFetchForAllPatterns();
protected Event<AuthRequired> authRequiredEvent();
protected Event<RequestPaused> requestPausedEvent();
}Manages console log operations, log entries, and provides conversion between CDP log formats and Selenium's logging system.
public class V102Log implements org.openqa.selenium.devtools.idealized.log.Log {
public Command<Void> enable();
public Command<Void> clear();
public Event<org.openqa.selenium.devtools.idealized.log.model.LogEntry> entryAdded();
}Manages browser targets (tabs, windows, workers), attachment/detachment operations, and target information retrieval.
public class V102Target implements org.openqa.selenium.devtools.idealized.target.Target {
public Command<Void> detachFromTarget(Optional<SessionID> sessionId, Optional<TargetID> targetId);
public Command<List<org.openqa.selenium.devtools.idealized.target.model.TargetInfo>> getTargets();
public Command<SessionID> attachToTarget(TargetID targetId);
public Command<Void> setAutoAttach();
}Core types used across the API:
// DevTools connection and command types
class DevTools { ... }
class Command<T> { ... }
class Event<T> { ... }
// User agent configuration
class UserAgent {
String userAgent();
String acceptLanguage();
String platform();
}
// Authentication credentials
class UsernameAndPassword {
String username();
String password();
}
// HTTP request/response types
class HttpRequest { ... }
class HttpResponse { ... }
// Either type for handling different response types
class Either<L, R> { ... }
// Target and session identifiers
class TargetID {
TargetID(String id);
String toString();
}
class SessionID {
SessionID(String id);
String toString();
}