Chrome DevTools Protocol (CDP) bindings for Selenium WebDriver version 138
—
Service registration for automatic CDP version discovery and integration with Selenium's version selection mechanism. Handles the automatic detection and initialization of Chrome DevTools Protocol version 138 support.
Registers the v138 implementation with Selenium's service discovery system.
/**
* CDP version registration service for automatic discovery
* Annotated with @AutoService for Java ServiceLoader integration
*/
@AutoService(CdpInfo.class)
public class v138CdpInfo extends CdpInfo {
public v138CdpInfo();
}Usage Note:
This class is typically not used directly by application code. It is automatically discovered and instantiated by Selenium's CdpVersionFinder when determining the appropriate CDP version for a given Chrome browser version.
The v138CdpInfo class registers version 138 support with the domains factory:
public v138CdpInfo() {
super(138, v138Domains::new);
}This constructor:
v138Domains::new) for creating domain instancesSelenium automatically selects the appropriate CDP version through this process:
CdpVersionFinder uses Java ServiceLoader to discover all available CdpInfo implementationsCdpInfo provides the domain factory for creating CDP bindingsCDP version 138 is designed to work with:
While you typically don't instantiate v138CdpInfo directly, here's how the automatic selection works:
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.devtools.DevTools;
// Chrome version 138 is automatically detected
ChromeOptions options = new ChromeOptions();
ChromeDriver driver = new ChromeDriver(options);
// DevTools automatically selects v138 implementation
DevTools devTools = driver.getDevTools();
devTools.createSession();
// The domains object is automatically a v138Domains instance
// if Chrome version 138 is running
var domains = devTools.getDomains(); // Returns v138Domains for Chrome 138
devTools.close();
driver.quit();You can verify which CDP version is being used:
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.devtools.DevTools;
import org.openqa.selenium.devtools.CdpVersionFinder;
ChromeDriver driver = new ChromeDriver();
// Get browser version
String browserVersion = driver.getCapabilities().getBrowserVersion();
System.out.println("Browser version: " + browserVersion);
// Get selected CDP version (requires access to internal APIs)
DevTools devTools = driver.getDevTools();
devTools.createSession();
// Check if v138 is being used by examining domain types
var domains = devTools.getDomains();
System.out.println("Domain implementation: " + domains.getClass().getSimpleName());
devTools.close();
driver.quit();The @AutoService(CdpInfo.class) annotation automatically generates the required service loader configuration file:
META-INF/services/org.openqa.selenium.devtools.CdpInfoThis file contains:
org.openqa.selenium.devtools.v138.v138CdpInfoThis enables the Java ServiceLoader mechanism to discover the v138 implementation at runtime.
Selenium typically includes multiple CDP versions simultaneously:
The CdpVersionFinder automatically selects the best match based on the detected browser version, providing forward and backward compatibility within reasonable bounds.
// Base CDP information class
abstract class CdpInfo {
protected CdpInfo(int version, Function<DevTools, Domains> domainFactory);
public abstract int getVersion();
public abstract Function<DevTools, Domains> getDomainFactory();
}
// Service discovery annotation
@interface AutoService {
Class<?>[] value(); // Service interface classes
}
// Domain factory function type
@FunctionalInterface
interface Function<DevTools, Domains> {
Domains apply(DevTools devtools);
}Install with Tessl CLI
npx tessl i tessl/maven-org-seleniumhq-selenium--selenium-devtools-v138