or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

console-logging.mddomain-management.mdindex.mdjavascript-integration.mdnetwork-operations.mdruntime-events.mdtarget-management.mdversion-system.md

version-system.mddocs/

0

# Version System

1

2

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.

3

4

## Capabilities

5

6

### CDP Version Registration

7

8

Registers the v138 implementation with Selenium's service discovery system.

9

10

```java { .api }

11

/**

12

* CDP version registration service for automatic discovery

13

* Annotated with @AutoService for Java ServiceLoader integration

14

*/

15

@AutoService(CdpInfo.class)

16

public class v138CdpInfo extends CdpInfo {

17

public v138CdpInfo();

18

}

19

```

20

21

**Usage Note:**

22

23

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.

24

25

### Automatic Version Selection

26

27

The v138CdpInfo class registers version 138 support with the domains factory:

28

29

```java

30

public v138CdpInfo() {

31

super(138, v138Domains::new);

32

}

33

```

34

35

This constructor:

36

- Registers support for CDP version 138

37

- Provides a factory method (`v138Domains::new`) for creating domain instances

38

- Enables automatic selection when Chrome version 138 is detected

39

40

## Version Selection Process

41

42

Selenium automatically selects the appropriate CDP version through this process:

43

44

1. **Browser Version Detection**: When a Chrome/Chromium browser is launched, Selenium detects its version

45

2. **Service Discovery**: The `CdpVersionFinder` uses Java ServiceLoader to discover all available `CdpInfo` implementations

46

3. **Version Matching**: The finder selects the CDP version that best matches the browser version (within a tolerance range)

47

4. **Domain Factory Creation**: The selected `CdpInfo` provides the domain factory for creating CDP bindings

48

49

## Browser Version Compatibility

50

51

CDP version 138 is designed to work with:

52

- **Primary target**: Chrome/Chromium version 138.x

53

- **Compatibility range**: Chrome versions 133-143 (within 5-version tolerance)

54

- **Fallback behavior**: May work with adjacent versions but with potential feature limitations

55

56

## Integration Example

57

58

While you typically don't instantiate `v138CdpInfo` directly, here's how the automatic selection works:

59

60

```java

61

import org.openqa.selenium.chrome.ChromeDriver;

62

import org.openqa.selenium.chrome.ChromeOptions;

63

import org.openqa.selenium.devtools.DevTools;

64

65

// Chrome version 138 is automatically detected

66

ChromeOptions options = new ChromeOptions();

67

ChromeDriver driver = new ChromeDriver(options);

68

69

// DevTools automatically selects v138 implementation

70

DevTools devTools = driver.getDevTools();

71

devTools.createSession();

72

73

// The domains object is automatically a v138Domains instance

74

// if Chrome version 138 is running

75

var domains = devTools.getDomains(); // Returns v138Domains for Chrome 138

76

77

devTools.close();

78

driver.quit();

79

```

80

81

## Manual Version Verification

82

83

You can verify which CDP version is being used:

84

85

```java

86

import org.openqa.selenium.chrome.ChromeDriver;

87

import org.openqa.selenium.devtools.DevTools;

88

import org.openqa.selenium.devtools.CdpVersionFinder;

89

90

ChromeDriver driver = new ChromeDriver();

91

92

// Get browser version

93

String browserVersion = driver.getCapabilities().getBrowserVersion();

94

System.out.println("Browser version: " + browserVersion);

95

96

// Get selected CDP version (requires access to internal APIs)

97

DevTools devTools = driver.getDevTools();

98

devTools.createSession();

99

100

// Check if v138 is being used by examining domain types

101

var domains = devTools.getDomains();

102

System.out.println("Domain implementation: " + domains.getClass().getSimpleName());

103

104

devTools.close();

105

driver.quit();

106

```

107

108

## Service Loader Configuration

109

110

The `@AutoService(CdpInfo.class)` annotation automatically generates the required service loader configuration file:

111

112

```

113

META-INF/services/org.openqa.selenium.devtools.CdpInfo

114

```

115

116

This file contains:

117

```

118

org.openqa.selenium.devtools.v138.v138CdpInfo

119

```

120

121

This enables the Java ServiceLoader mechanism to discover the v138 implementation at runtime.

122

123

## Multiple Version Support

124

125

Selenium typically includes multiple CDP versions simultaneously:

126

127

- **v137**: For Chrome 137 and compatible versions

128

- **v138**: For Chrome 138 and compatible versions

129

- **v139**: For Chrome 139 and compatible versions

130

131

The `CdpVersionFinder` automatically selects the best match based on the detected browser version, providing forward and backward compatibility within reasonable bounds.

132

133

## Types

134

135

```java { .api }

136

// Base CDP information class

137

abstract class CdpInfo {

138

protected CdpInfo(int version, Function<DevTools, Domains> domainFactory);

139

public abstract int getVersion();

140

public abstract Function<DevTools, Domains> getDomainFactory();

141

}

142

143

// Service discovery annotation

144

@interface AutoService {

145

Class<?>[] value(); // Service interface classes

146

}

147

148

// Domain factory function type

149

@FunctionalInterface

150

interface Function<DevTools, Domains> {

151

Domains apply(DevTools devtools);

152

}

153

```