Chrome DevTools Protocol version 115 bindings for Selenium Java WebDriver enabling programmatic browser debugging capabilities
npx @tessl/cli install tessl/maven-org-seleniumhq-selenium--selenium-devtools-v115@4.13.0Selenium DevTools v115 provides Java bindings for Chrome DevTools Protocol version 115, enabling programmatic access to Chrome browser debugging capabilities within Selenium WebDriver. It offers automated code generation from CDP protocol specifications to create type-safe Java APIs for browser automation, network monitoring, JavaScript execution, logging, and event handling.
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-devtools-v115</artifactId>
<version>4.13.0</version>
</dependency>import org.openqa.selenium.devtools.v115.v115Domains;
import org.openqa.selenium.devtools.DevTools;Common for working with specific domains:
import org.openqa.selenium.devtools.v115.v115Events;
import org.openqa.selenium.devtools.v115.v115Javascript;
import org.openqa.selenium.devtools.v115.v115Network;
import org.openqa.selenium.devtools.v115.v115Target;
import org.openqa.selenium.devtools.v115.v115Log;import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.devtools.DevTools;
import org.openqa.selenium.devtools.v115.v115Domains;
// Initialize WebDriver with DevTools support
ChromeDriver driver = new ChromeDriver();
DevTools devTools = driver.getDevTools();
devTools.createSession();
// Create domains instance
v115Domains domains = new v115Domains(devTools);
// Listen to console events
domains.events().addConsoleListener(event -> {
System.out.println("Console: " + event.getType() + " - " + event.getMessages());
});
// Add JavaScript binding
domains.javascript().addJsBinding("myCallback");
// Set user agent
domains.network().setUserAgent("Custom User Agent v1.0");
// Navigate and interact
driver.get("https://example.com");
driver.quit();Selenium DevTools v115 is built around several key architectural layers:
v115CdpInfo service providerThis layered architecture allows developers to use either high-level idealized APIs for common use cases or drop down to low-level CDP commands for advanced scenarios.
Central access point for all Chrome DevTools Protocol domains, providing unified initialization and lifecycle management.
public class v115Domains implements Domains {
public v115Domains(DevTools devtools);
public Events<?, ?> events();
public Javascript<?, ?> javascript();
public Network<?, ?> network();
public Target target();
public Log log();
}Comprehensive event handling for console messages, JavaScript exceptions, and runtime events with idealized conversion and filtering capabilities.
public class v115Events extends Events<ConsoleAPICalled, ExceptionThrown> {
public v115Events(DevTools devtools);
protected Command<Void> enableRuntime();
protected Command<Void> disableRuntime();
protected Event<ConsoleAPICalled> consoleEvent();
protected Event<ExceptionThrown> exceptionThrownEvent();
protected ConsoleEvent toConsoleEvent(ConsoleAPICalled event);
protected JavascriptException toJsException(ExceptionThrown event);
}JavaScript code injection, binding management, and script execution coordination with full lifecycle control and event monitoring.
public class v115Javascript extends Javascript<ScriptIdentifier, BindingCalled> {
public v115Javascript(DevTools devtools);
protected Command<Void> enableRuntime();
protected Command<Void> disableRuntime();
protected Command<Void> doAddJsBinding(String scriptName);
protected Command<Void> doRemoveJsBinding(String scriptName);
protected Command<ScriptIdentifier> addScriptToEvaluateOnNewDocument(String script);
protected Command<Void> removeScriptToEvaluateOnNewDocument(ScriptIdentifier id);
protected Event<BindingCalled> bindingCalledEvent();
protected String extractPayload(BindingCalled event);
}Advanced network traffic interception, request/response manipulation, authentication handling, and user agent override capabilities.
public class v115Network extends Network<AuthRequired, RequestPaused> {
public v115Network(DevTools devTools);
protected Command<Void> setUserAgentOverride(UserAgent userAgent);
protected Command<Void> enableNetworkCaching();
protected Command<Void> disableNetworkCaching();
protected Command<Void> enableFetchForAllPatterns();
protected Command<Void> disableFetch();
protected Event<AuthRequired> authRequiredEvent();
protected Command<Void> continueWithAuth(AuthRequired authRequired, UsernameAndPassword credentials);
protected Command<Void> cancelAuth(AuthRequired authRequired);
public Event<RequestPaused> requestPausedEvent();
public Either<HttpRequest, HttpResponse> createSeMessages(RequestPaused pausedReq);
protected Command<Void> continueRequest(RequestPaused pausedReq, HttpRequest req);
protected Command<Void> fulfillRequest(RequestPaused pausedReq, HttpResponse res);
}Browser target (tab/window) management, debugging session control, and multi-target coordination with attachment and detachment capabilities.
public class v115Target implements Target {
public Command<Void> detachFromTarget(Optional<SessionID> sessionId, Optional<TargetID> targetId);
public Command<List<TargetInfo>> getTargets();
public Command<SessionID> attachToTarget(TargetID targetId);
public Command<Void> setAutoAttach();
public Event<TargetID> detached();
}Browser console log collection, filtering, and event stream management with level conversion and timestamp handling.
public class v115Log implements Log {
public Command<Void> enable();
public Command<Void> clear();
public Event<LogEntry> entryAdded();
}// Service Provider Registration
@AutoService(CdpInfo.class)
public class v115CdpInfo extends CdpInfo {
public v115CdpInfo();
}
// Idealized Model Types
public class ConsoleEvent {
public String getType();
public Instant getTimestamp();
public List<Object> getArgs();
public List<String> getMessages();
}
public class ScriptId {
// Opaque wrapper for script identifiers
}
public class UserAgent {
public String userAgent();
public Optional<String> acceptLanguage();
public Optional<String> platform();
}
// Target Model Types
public class TargetInfo {
public TargetID getTargetId();
public String getType();
public String getTitle();
public String getUrl();
public Boolean getAttached();
public Optional<TargetID> getOpenerId();
public Optional<BrowserContextID> getBrowserContextId();
}
public class SessionID {
public String toString();
}
public class TargetID {
public String toString();
}
// Log Model Types
public class LogEntry {
public String getKind();
public org.openqa.selenium.logging.LogEntry getEntry();
}
// Runtime Model Types
public class RemoteObject {
public String getType();
public Object getValue();
}