Chrome DevTools Protocol (CDP) client library for Chrome version 105, providing Java bindings for browser automation and debugging capabilities
—
Direct access to all generated Chrome DevTools Protocol domains for advanced use cases requiring protocol-level control. Includes 41+ domains with full type-safe Java bindings for Chrome version 105.
The most commonly used and stable CDP domains for browser automation.
JavaScript runtime API for code execution, object inspection, and runtime control.
import org.openqa.selenium.devtools.v105.runtime.Runtime;
import org.openqa.selenium.devtools.v105.runtime.model.*;
// Enable/disable runtime domain
public static Command<Void> enable();
public static Command<Void> disable();
// JavaScript evaluation
public static Command<EvaluateResponse> evaluate(String expression);
public static Command<EvaluateResponse> evaluate(String expression,
Optional<String> objectGroup, Optional<Boolean> includeCommandLineAPI);
// Object inspection
public static Command<GetPropertiesResponse> getProperties(RemoteObjectId objectId);
public static Command<Void> releaseObject(RemoteObjectId objectId);
// Console and binding events
public static Event<ConsoleAPICalled> consoleAPICalled();
public static Event<ExceptionThrown> exceptionThrown();
public static Event<BindingCalled> bindingCalled();Usage Examples:
// Direct runtime evaluation
devTools.send(Runtime.enable());
EvaluateResponse result = devTools.send(Runtime.evaluate("document.title"));
System.out.println("Page title: " + result.getResult().getValue());
// Object inspection
devTools.send(Runtime.evaluate("document.body", Optional.empty(), Optional.of(true)))
.getResult().getObjectId()
.ifPresent(objectId -> {
GetPropertiesResponse props = devTools.send(Runtime.getProperties(objectId));
props.getResult().forEach(prop ->
System.out.println(prop.getName() + ": " + prop.getValue()));
});Network control and monitoring at the protocol level.
import org.openqa.selenium.devtools.v105.network.Network;
import org.openqa.selenium.devtools.v105.network.model.*;
// Enable/disable network domain
public static Command<Void> enable();
public static Command<Void> disable();
// Network configuration
public static Command<Void> setUserAgentOverride(String userAgent, Optional<String> acceptLanguage, Optional<String> platform);
public static Command<Void> setCacheDisabled(Boolean cacheDisabled);
public static Command<Void> setBypassServiceWorker(Boolean bypass);
// Request/response events
public static Event<RequestWillBeSent> requestWillBeSent();
public static Event<ResponseReceived> responseReceived();
public static Event<LoadingFinished> loadingFinished();
public static Event<LoadingFailed> loadingFailed();Usage Examples:
// Monitor network traffic
devTools.send(Network.enable());
Network.requestWillBeSent().addListener(request -> {
System.out.println("Request: " + request.getRequest().getMethod() + " " + request.getRequest().getUrl());
});
Network.responseReceived().addListener(response -> {
System.out.println("Response: " + response.getResponse().getStatus() + " " + response.getResponse().getUrl());
});Page lifecycle, navigation, and document control.
import org.openqa.selenium.devtools.v105.page.Page;
import org.openqa.selenium.devtools.v105.page.model.*;
// Enable/disable page domain
public static Command<Void> enable();
public static Command<Void> disable();
// Navigation
public static Command<NavigateResponse> navigate(String url);
public static Command<Void> reload(Optional<Boolean> ignoreCache, Optional<String> scriptToEvaluateOnLoad);
// Script injection
public static Command<ScriptIdentifier> addScriptToEvaluateOnNewDocument(String source);
public static Command<Void> removeScriptToEvaluateOnNewDocument(ScriptIdentifier identifier);
// Page events
public static Event<FrameNavigated> frameNavigated();
public static Event<LoadEventFired> loadEventFired();
public static Event<DomContentEventFired> domContentEventFired();Usage Examples:
// Page navigation and events
devTools.send(Page.enable());
Page.frameNavigated().addListener(nav ->
System.out.println("Navigated to: " + nav.getFrame().getUrl()));
Page.loadEventFired().addListener(event ->
System.out.println("Page load completed at: " + event.getTimestamp()));
// Navigate programmatically
NavigateResponse navResult = devTools.send(Page.navigate("https://example.com"));
System.out.println("Navigation ID: " + navResult.getLoaderId());Domains for debugging JavaScript and performance analysis.
JavaScript debugging capabilities including breakpoints and execution control.
import org.openqa.selenium.devtools.v105.debugger.Debugger;
import org.openqa.selenium.devtools.v105.debugger.model.*;
// Enable/disable debugger
public static Command<Void> enable();
public static Command<Void> disable();
// Breakpoint management
public static Command<SetBreakpointByUrlResponse> setBreakpointByUrl(int lineNumber, String url);
public static Command<Void> removeBreakpoint(BreakpointId breakpointId);
// Execution control
public static Command<Void> resume();
public static Command<Void> stepOver();
public static Command<Void> stepInto();
public static Command<Void> stepOut();
// Debugger events
public static Event<Paused> paused();
public static Event<Resumed> resumed();
public static Event<ScriptParsed> scriptParsed();Performance profiling for JavaScript execution analysis.
import org.openqa.selenium.devtools.v105.profiler.Profiler;
import org.openqa.selenium.devtools.v105.profiler.model.*;
// Enable/disable profiler
public static Command<Void> enable();
public static Command<Void> disable();
// Profiling control
public static Command<Void> start();
public static Command<StopResponse> stop();
// Sampling configuration
public static Command<Void> setSamplingInterval(int interval);
// Profile events
public static Event<ConsoleProfileStarted> consoleProfileStarted();
public static Event<ConsoleProfileFinished> consoleProfileFinished();Domains for browser-level control and emulation.
Browser-level operations and information.
import org.openqa.selenium.devtools.v105.browser.Browser;
import org.openqa.selenium.devtools.v105.browser.model.*;
// Browser information
public static Command<GetVersionResponse> getVersion();
public static Command<GetBrowserCommandLineResponse> getBrowserCommandLine();
// Window management
public static Command<GetWindowBoundsResponse> getWindowBounds(WindowId windowId);
public static Command<Void> setWindowBounds(WindowId windowId, Bounds bounds);
// Permission management
public static Command<Void> grantPermissions(List<PermissionType> permissions, Optional<String> origin);
public static Command<Void> resetPermissions();Device and environment emulation capabilities.
import org.openqa.selenium.devtools.v105.emulation.Emulation;
import org.openqa.selenium.devtools.v105.emulation.model.*;
// Device emulation
public static Command<Void> setDeviceMetricsOverride(int width, int height, Number deviceScaleFactor, Boolean mobile);
public static Command<Void> clearDeviceMetricsOverride();
// Geolocation emulation
public static Command<Void> setGeolocationOverride(Optional<Number> latitude, Optional<Number> longitude, Optional<Number> accuracy);
public static Command<Void> clearGeolocationOverride();
// Media emulation
public static Command<Void> setEmulatedMedia(Optional<String> media, Optional<List<MediaFeature>> features);
// Timezone emulation
public static Command<Void> setTimezoneOverride(String timezoneId);Domains for security monitoring and storage management.
Security state monitoring and certificate handling.
import org.openqa.selenium.devtools.v105.security.Security;
import org.openqa.selenium.devtools.v105.security.model.*;
// Enable security monitoring
public static Command<Void> enable();
public static Command<Void> disable();
// Certificate handling
public static Command<Void> handleCertificateError(int eventId, CertificateErrorAction action);
public static Command<Void> setOverrideCertificateErrors(Boolean override);
// Security events
public static Event<SecurityStateChanged> securityStateChanged();
public static Event<CertificateError> certificateError();Browser storage management (localStorage, sessionStorage, IndexedDB, etc.).
import org.openqa.selenium.devtools.v105.storage.Storage;
import org.openqa.selenium.devtools.v105.storage.model.*;
// Storage clearing
public static Command<Void> clearDataForOrigin(String origin, String storageTypes);
// Cache storage
public static Command<GetCacheStorageResponse> getCacheStorage(String origin);
public static Command<Void> deleteCacheStorage(String origin, String cacheName);
// Storage events
public static Event<CacheStorageContentUpdated> cacheStorageContentUpdated();
public static Event<CacheStorageListUpdated> cacheStorageListUpdated();Additional domains for specialized use cases (marked as experimental).
Available Experimental Domains:
// Enable domain
devTools.send(Runtime.enable());
// Send command
EvaluateResponse response = devTools.send(Runtime.evaluate("window.location.href"));
// Process result
if (response.getExceptionDetails().isPresent()) {
System.err.println("JavaScript error: " + response.getExceptionDetails().get().getText());
} else {
System.out.println("Result: " + response.getResult().getValue());
}
// Clean up
devTools.send(Runtime.disable());// Subscribe to events before enabling domain
Runtime.consoleAPICalled().addListener(consoleEvent -> {
System.out.println("Console " + consoleEvent.getType() + ": " +
consoleEvent.getArgs().stream()
.map(arg -> arg.getValue().orElse(arg.getDescription().orElse("undefined")))
.collect(Collectors.joining(" ")));
});
// Enable domain to start receiving events
devTools.send(Runtime.enable());
// Events will now be delivered to the listenerpublic class AdvancedBrowserControl {
public void setupComprehensiveMonitoring(DevTools devTools) {
// Enable multiple domains
devTools.send(Runtime.enable());
devTools.send(Network.enable());
devTools.send(Page.enable());
devTools.send(Security.enable());
// Set up cross-domain event handling
setupEventHandlers();
// Configure browser state
devTools.send(Network.setCacheDisabled(true));
devTools.send(Emulation.setUserAgentOverride("Test-Bot/1.0", Optional.empty(), Optional.empty()));
}
private void setupEventHandlers() {
// Network monitoring
Network.requestWillBeSent().addListener(this::logRequest);
Network.responseReceived().addListener(this::logResponse);
// Page lifecycle
Page.frameNavigated().addListener(this::handleNavigation);
Page.loadEventFired().addListener(this::handlePageLoad);
// Runtime monitoring
Runtime.consoleAPICalled().addListener(this::handleConsole);
Runtime.exceptionThrown().addListener(this::handleException);
// Security monitoring
Security.securityStateChanged().addListener(this::handleSecurityChange);
}
}// Base command type
public class Command<T> {
String getMethod();
Map<String, Object> getParams();
}
// Base event type
public class Event<T> {
String getMethod();
Function<JsonInput, T> getMapper();
}
// DevTools session
public interface DevTools {
<T> T send(Command<T> command);
<T> void addListener(Event<T> event, Consumer<T> listener);
void createSession();
void close();
}// Evaluation response
public class EvaluateResponse {
RemoteObject getResult();
Optional<ExceptionDetails> getExceptionDetails();
}
// Remote object representation
public class RemoteObject {
RemoteObject.Type getType();
Optional<Object> getValue();
Optional<String> getDescription();
Optional<RemoteObjectId> getObjectId();
}
// Exception details
public class ExceptionDetails {
String getText();
int getLineNumber();
int getColumnNumber();
Optional<String> getUrl();
Optional<StackTrace> getStackTrace();
}Install with Tessl CLI
npx tessl i tessl/maven-org-seleniumhq-selenium--selenium-devtools-v105