Chrome DevTools Protocol (CDP) bindings for Selenium WebDriver targeting Chromium version 85
npx @tessl/cli install tessl/maven-org-seleniumhq-selenium--selenium-devtools-v85@4.29.0Selenium DevTools v85 provides Java bindings for the Chrome DevTools Protocol (CDP) targeting Chromium version 85. This package contains the version-specific implementation classes that are automatically discovered and used by the Selenium DevTools framework. While users typically interact with the high-level DevTools API, this package provides the underlying v85-specific functionality for network monitoring, JavaScript execution, console events, logging, and target management.
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-devtools-v85</artifactId>
<version>4.29.0</version>
</dependency>import org.openqa.selenium.devtools.v85.V85Domains;
import org.openqa.selenium.devtools.v85.V85CdpInfo;
import org.openqa.selenium.devtools.DevTools;High-Level API (Recommended): Users typically access DevTools functionality through the high-level API, which automatically uses this v85 implementation when connected to a compatible Chromium version:
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.devtools.DevTools;
import org.openqa.selenium.devtools.HasDevTools;
import org.openqa.selenium.devtools.events.ConsoleEvent;
// Create Chrome driver with DevTools
ChromeDriver driver = new ChromeDriver();
DevTools devTools = ((HasDevTools) driver).getDevTools();
devTools.createSession();
// Use high-level API - automatically uses v85 implementation
devTools.getDomains().events().addConsoleListener(event -> {
System.out.println("Console: " + event.getType() + " - " + event.getMessages());
});
// Network interception (high-level API)
devTools.getDomains().network().interceptTrafficWith(filter -> {
// Process HTTP requests and responses
return req -> {
// Process request and return response or NetworkInterceptor.PROCEED_WITH_REQUEST
return org.openqa.selenium.devtools.NetworkInterceptor.PROCEED_WITH_REQUEST;
};
});
// Close session when done
devTools.close();
driver.quit();Direct v85 API (Internal): This package also provides direct access to v85-specific classes for advanced use cases:
import org.openqa.selenium.devtools.v85.V85Domains;
import org.openqa.selenium.devtools.v85.runtime.Runtime;
import org.openqa.selenium.devtools.v85.runtime.model.ConsoleAPICalled;
import java.util.Optional;
// Access v85 implementation directly
V85Domains domains = new V85Domains(devTools);
// Enable runtime and monitor console events
devTools.send(Runtime.enable());
devTools.addListener(Runtime.consoleAPICalled(), event -> {
System.out.println("Console: " + event.getType() + " - " + event.getArgs());
});The DevTools v85 package is built around several key components:
Service Discovery Pattern: This package uses Google's AutoService to automatically register the V85CdpInfo class, which tells the DevTools framework that this implementation supports Chromium version 85. When a DevTools session connects to a compatible browser, this implementation is automatically selected and used.
Network monitoring and HTTP request/response interception capabilities. Monitor network traffic, modify requests/responses, handle authentication challenges, and control caching behavior.
public class V85Network extends Network<AuthRequired, RequestPaused> {
public V85Network(DevTools devTools);
// Public methods accessible to the DevTools framework
public Event<RequestPaused> requestPausedEvent();
public Either<HttpRequest, HttpResponse> createSeMessages(RequestPaused pausedReq);
// Note: Most functionality is accessed through high-level DevTools API:
// devTools.getDomains().network().interceptTraffic(...)
// devTools.getDomains().network().disable()
}JavaScript execution in different browser contexts with binding support. Execute scripts, create persistent bindings between browser and Java, and inject scripts on page load.
public class V85Javascript extends Javascript<ScriptIdentifier, BindingCalled> {
public V85Javascript(DevTools devtools);
// Note: JavaScript functionality is typically accessed through:
// devTools.getDomains().javascript().pin("script")
// devTools.getDomains().javascript().addJsBinding("name", callback)
// Or direct CDP commands: Runtime.addBinding(), Runtime.evaluate()
}Runtime event monitoring including console API calls, JavaScript exceptions, and error handling. Capture browser console output and JavaScript runtime errors in real-time.
public class V85Events extends Events<ConsoleAPICalled, ExceptionThrown> {
public V85Events(DevTools devtools);
// Note: Console events are typically accessed through:
// devTools.getDomains().events().addConsoleListener(event -> {...})
// devTools.getDomains().events().addJavascriptExceptionListener(exception -> {...})
}Browser log capture and management. Access browser logs with different severity levels and timestamps for debugging and monitoring.
public class V85Log implements org.openqa.selenium.devtools.idealized.log.Log {
public Command<Void> enable();
public Command<Void> clear();
public Event<LogEntry> entryAdded();
}Browser target (tab/window) management and session handling. Create, attach to, and manage browser contexts and targets for multi-tab automation.
public class V85Target implements org.openqa.selenium.devtools.idealized.target.Target {
public Command<List<TargetInfo>> getTargets();
public Command<SessionID> attachToTarget(TargetID targetId);
public Command<Void> detachFromTarget(Optional<SessionID> sessionId, Optional<TargetID> targetId);
public Command<Void> setAutoAttach();
public Event<TargetID> detached();
}/**
* Main CDP information and version handler
*/
public class V85CdpInfo extends CdpInfo {
public V85CdpInfo();
}
/**
* Central domain access point
*/
public class V85Domains implements Domains {
public V85Domains(DevTools devtools);
public Events<?, ?> events();
public Javascript<?, ?> javascript();
public Network<?, ?> network();
public Target target();
public Log log();
}
/**
* User agent configuration for network requests (nested class in Network)
*/
public static class Network.UserAgent {
public UserAgent(String userAgent);
public UserAgent acceptLanguage(String acceptLanguage);
public UserAgent platform(String platform);
public String userAgent();
public Optional<String> acceptLanguage();
public Optional<String> platform();
}
/**
* Username and password credentials
*/
public class UsernameAndPassword {
public String username();
public String password();
}