or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

edge-driver-info.mdedge-driver-service.mdedge-driver.mdedge-options.mdindex.md

edge-driver-info.mddocs/

0

# Edge Driver Info

1

2

EdgeDriverInfo provides metadata, capability matching, and factory methods for EdgeDriver instances. It integrates with Selenium's WebDriverInfo service provider interface to enable automatic driver selection and creation based on browser capabilities.

3

4

## Capabilities

5

6

### EdgeDriverInfo Class

7

8

Metadata provider and factory for EdgeDriver instances with capability matching and WebDriver integration.

9

10

```java { .api }

11

/**

12

* WebDriverInfo implementation for Microsoft Edge browser

13

* Provides metadata and factory methods for EdgeDriver instances

14

*/

15

@AutoService(WebDriverInfo.class)

16

public class EdgeDriverInfo extends ChromiumDriverInfo {

17

/**

18

* Gets human-readable display name for Edge

19

* @return "Edge"

20

*/

21

public String getDisplayName();

22

23

/**

24

* Gets canonical capabilities for Edge browser

25

* @return ImmutableCapabilities with browserName set to "MicrosoftEdge"

26

*/

27

public Capabilities getCanonicalCapabilities();

28

29

/**

30

* Checks if given capabilities are supported by EdgeDriver

31

* @param capabilities Capabilities to check

32

* @return true if capabilities are supported (Edge, WebView2, or ms:edgeOptions)

33

*/

34

public boolean isSupporting(Capabilities capabilities);

35

36

/**

37

* Checks if EdgeDriver supports Chrome DevTools Protocol

38

* @return true (EdgeDriver supports CDP)

39

*/

40

public boolean isSupportingCdp();

41

42

/**

43

* Checks if EdgeDriver supports WebDriver BiDi protocol

44

* @return true (EdgeDriver supports BiDi)

45

*/

46

public boolean isSupportingBiDi();

47

48

/**

49

* Checks if EdgeDriver executable is available on the system

50

* @return true if msedgedriver is available and can be executed

51

*/

52

public boolean isAvailable();

53

54

/**

55

* Checks if EdgeDriver executable is present on the system

56

* @return true if msedgedriver executable exists

57

*/

58

public boolean isPresent();

59

60

/**

61

* Creates EdgeDriver instance if capabilities are supported and driver is available

62

* @param capabilities Desired capabilities for the driver

63

* @return Optional containing EdgeDriver if creation successful, empty otherwise

64

* @throws SessionNotCreatedException if driver cannot be created

65

*/

66

public Optional<WebDriver> createDriver(Capabilities capabilities) throws SessionNotCreatedException;

67

}

68

```

69

70

**Usage Examples:**

71

72

```java

73

import org.openqa.selenium.edge.EdgeDriverInfo;

74

import org.openqa.selenium.edge.EdgeOptions;

75

import org.openqa.selenium.Capabilities;

76

import org.openqa.selenium.WebDriver;

77

78

// Get driver info instance

79

EdgeDriverInfo driverInfo = new EdgeDriverInfo();

80

81

// Check basic information

82

String displayName = driverInfo.getDisplayName(); // "Edge"

83

Capabilities canonical = driverInfo.getCanonicalCapabilities();

84

85

// Check capabilities and availability

86

boolean available = driverInfo.isAvailable();

87

boolean present = driverInfo.isPresent();

88

boolean supportsCdp = driverInfo.isSupportingCdp(); // true

89

boolean supportsBidi = driverInfo.isSupportingBiDi(); // true

90

```

91

92

### Capability Matching

93

94

EdgeDriverInfo supports multiple capability patterns for Edge and WebView2:

95

96

```java { .api }

97

/**

98

* Supported capability patterns:

99

* - browserName: "MicrosoftEdge"

100

* - browserName: "webview2"

101

* - ms:edgeOptions capability present

102

*/

103

public boolean isSupporting(Capabilities capabilities);

104

```

105

106

**Usage Examples:**

107

108

```java

109

EdgeDriverInfo driverInfo = new EdgeDriverInfo();

110

111

// Edge browser capabilities

112

Capabilities edgeCapabilities = new ImmutableCapabilities(

113

CapabilityType.BROWSER_NAME, "MicrosoftEdge"

114

);

115

boolean supportsEdge = driverInfo.isSupporting(edgeCapabilities); // true

116

117

// WebView2 capabilities

118

Capabilities webViewCapabilities = new ImmutableCapabilities(

119

CapabilityType.BROWSER_NAME, "webview2"

120

);

121

boolean supportsWebView = driverInfo.isSupporting(webViewCapabilities); // true

122

123

// EdgeOptions capabilities

124

EdgeOptions options = new EdgeOptions();

125

boolean supportsOptions = driverInfo.isSupporting(options); // true

126

127

// Unsupported browser

128

Capabilities chromeCapabilities = new ImmutableCapabilities(

129

CapabilityType.BROWSER_NAME, "chrome"

130

);

131

boolean supportsChrome = driverInfo.isSupporting(chromeCapabilities); // false

132

```

133

134

### Driver Creation

135

136

Factory method for creating EdgeDriver instances with capability validation:

137

138

```java { .api }

139

/**

140

* Creates EdgeDriver if capabilities are supported and driver is available

141

* @param capabilities Desired capabilities

142

* @return Optional<WebDriver> containing EdgeDriver or empty if cannot create

143

*/

144

public Optional<WebDriver> createDriver(Capabilities capabilities);

145

```

146

147

**Usage Examples:**

148

149

```java

150

EdgeDriverInfo driverInfo = new EdgeDriverInfo();

151

152

// Create driver with Edge capabilities

153

EdgeOptions options = new EdgeOptions();

154

options.addArguments("--headless");

155

156

Optional<WebDriver> driverOptional = driverInfo.createDriver(options);

157

if (driverOptional.isPresent()) {

158

WebDriver driver = driverOptional.get();

159

driver.get("https://example.com");

160

driver.quit();

161

} else {

162

System.out.println("Cannot create EdgeDriver - not available or unsupported");

163

}

164

165

// Create WebView2 driver

166

EdgeOptions webViewOptions = new EdgeOptions();

167

webViewOptions.useWebView(true);

168

169

Optional<WebDriver> webViewDriver = driverInfo.createDriver(webViewOptions);

170

if (webViewDriver.isPresent()) {

171

WebDriver driver = webViewDriver.get();

172

// Use for WebView2 automation

173

driver.quit();

174

}

175

```

176

177

### System Availability Checking

178

179

Methods to verify EdgeDriver executable availability:

180

181

```java { .api }

182

/**

183

* Checks if EdgeDriver is available (executable exists and can run)

184

* @return true if msedgedriver is available

185

*/

186

public boolean isAvailable();

187

188

/**

189

* Checks if EdgeDriver is present (executable file exists)

190

* @return true if msedgedriver executable exists

191

*/

192

public boolean isPresent();

193

```

194

195

**Usage Examples:**

196

197

```java

198

EdgeDriverInfo driverInfo = new EdgeDriverInfo();

199

200

// Check driver availability before creating tests

201

if (driverInfo.isAvailable()) {

202

System.out.println("EdgeDriver is available and ready to use");

203

204

// Run Edge automation tests

205

EdgeDriver driver = new EdgeDriver();

206

// ... test code

207

driver.quit();

208

209

} else if (driverInfo.isPresent()) {

210

System.out.println("EdgeDriver executable found but may not be functional");

211

} else {

212

System.out.println("EdgeDriver not found - please install msedgedriver");

213

}

214

215

// Use in test setup

216

@BeforeClass

217

public static void checkDriverAvailability() {

218

EdgeDriverInfo info = new EdgeDriverInfo();

219

Assume.assumeTrue("EdgeDriver not available", info.isAvailable());

220

}

221

```

222

223

### Protocol Support Checking

224

225

Methods to verify protocol support capabilities:

226

227

```java { .api }

228

/**

229

* Checks Chrome DevTools Protocol support

230

* @return true (EdgeDriver supports CDP)

231

*/

232

public boolean isSupportingCdp();

233

234

/**

235

* Checks WebDriver BiDi protocol support

236

* @return true (EdgeDriver supports BiDi)

237

*/

238

public boolean isSupportingBiDi();

239

```

240

241

**Usage Examples:**

242

243

```java

244

EdgeDriverInfo driverInfo = new EdgeDriverInfo();

245

246

// Check CDP support for advanced debugging

247

if (driverInfo.isSupportingCdp()) {

248

EdgeDriver driver = new EdgeDriver();

249

250

// Use CDP features

251

DevTools devTools = driver.getDevTools();

252

devTools.createSession();

253

// ... CDP operations

254

255

driver.quit();

256

}

257

258

// Check BiDi support for modern WebDriver features

259

if (driverInfo.isSupportingBiDi()) {

260

// Use WebDriver BiDi features when available

261

System.out.println("BiDi protocol supported");

262

}

263

```

264

265

### Integration with WebDriverManager

266

267

EdgeDriverInfo integrates with Selenium's service provider interface:

268

269

```java

270

// EdgeDriverInfo is automatically discovered via @AutoService annotation

271

// and can be used by WebDriverManager for automatic driver selection

272

273

ServiceLoader<WebDriverInfo> drivers = ServiceLoader.load(WebDriverInfo.class);

274

for (WebDriverInfo driverInfo : drivers) {

275

if (driverInfo instanceof EdgeDriverInfo) {

276

EdgeDriverInfo edgeInfo = (EdgeDriverInfo) driverInfo;

277

if (edgeInfo.isAvailable()) {

278

// EdgeDriver is available for use

279

}

280

}

281

}

282

```

283

284

### Error Handling

285

286

EdgeDriverInfo throws standard exceptions during driver creation:

287

288

```java { .api }

289

// Common exceptions

290

SessionNotCreatedException - When EdgeDriver session cannot be created

291

WebDriverException - General driver creation errors

292

IllegalArgumentException - Invalid capabilities provided

293

```

294

295

**Usage Examples:**

296

297

```java

298

EdgeDriverInfo driverInfo = new EdgeDriverInfo();

299

300

try {

301

EdgeOptions options = new EdgeOptions();

302

// Invalid binary path

303

options.setBinary("/nonexistent/path/to/edge");

304

305

Optional<WebDriver> driver = driverInfo.createDriver(options);

306

if (driver.isEmpty()) {

307

System.out.println("Driver creation failed - check capabilities and availability");

308

}

309

310

} catch (SessionNotCreatedException e) {

311

System.err.println("Cannot create Edge session: " + e.getMessage());

312

} catch (WebDriverException e) {

313

System.err.println("Edge driver error: " + e.getMessage());

314

}

315

```

316

317

## Types

318

319

```java { .api }

320

import org.openqa.selenium.WebDriverInfo;

321

import org.openqa.selenium.WebDriver;

322

import org.openqa.selenium.Capabilities;

323

import org.openqa.selenium.ImmutableCapabilities;

324

import org.openqa.selenium.SessionNotCreatedException;

325

import org.openqa.selenium.chromium.ChromiumDriverInfo;

326

import org.openqa.selenium.remote.CapabilityType;

327

import com.google.auto.service.AutoService;

328

import java.util.Optional;

329

```