or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

index.md

index.mddocs/

0

# Selenium Opera Driver

1

2

Selenium Opera Driver provides WebDriver implementation for controlling Opera browsers through the operadriver executable. This driver enables automated testing of web applications using Opera browsers but is deprecated due to operadriver's lack of W3C WebDriver standard support.

3

4

## Package Information

5

6

- **Package Name**: selenium-opera-driver

7

- **Package Type**: maven

8

- **Language**: Java

9

- **Group ID**: org.seleniumhq.selenium

10

- **Artifact ID**: selenium-opera-driver

11

- **Installation**: Add to Maven dependencies or include in Bazel BUILD file

12

13

Maven dependency:

14

```xml

15

<dependency>

16

<groupId>org.seleniumhq.selenium</groupId>

17

<artifactId>selenium-opera-driver</artifactId>

18

<version>4.4.0</version>

19

</dependency>

20

```

21

22

## Core Imports

23

24

```java

25

import org.openqa.selenium.opera.OperaDriver;

26

import org.openqa.selenium.opera.OperaOptions;

27

import org.openqa.selenium.opera.OperaDriverService;

28

import org.openqa.selenium.opera.OperaDriverInfo;

29

import org.openqa.selenium.Capabilities;

30

import org.openqa.selenium.WebDriver;

31

import org.openqa.selenium.html5.LocalStorage;

32

import org.openqa.selenium.html5.SessionStorage;

33

import org.openqa.selenium.html5.Location;

34

import org.openqa.selenium.html5.LocationContext;

35

import org.openqa.selenium.html5.WebStorage;

36

import org.openqa.selenium.remote.FileDetector;

37

import com.google.auto.service.AutoService;

38

```

39

40

## Basic Usage

41

42

```java

43

import org.openqa.selenium.opera.OperaDriver;

44

import org.openqa.selenium.opera.OperaOptions;

45

import org.openqa.selenium.opera.OperaDriverService;

46

47

// Basic usage with default options

48

OperaDriver driver = new OperaDriver();

49

50

// With custom options (recommended approach)

51

OperaOptions options = new OperaOptions();

52

options.setBinary("/path/to/opera");

53

options.addArguments("--headless", "--no-sandbox");

54

OperaDriver driver = new OperaDriver(options);

55

56

// With custom service configuration

57

OperaDriverService service = new OperaDriverService.Builder()

58

.withVerbose(true)

59

.withSilent(false)

60

.usingAnyFreePort()

61

.build();

62

OperaDriver driver = new OperaDriver(service, options);

63

64

// Use driver for automation

65

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

66

// ... perform actions

67

driver.quit();

68

```

69

70

## Architecture

71

72

The Opera Driver consists of several key components:

73

74

- **OperaDriver**: Main WebDriver implementation extending RemoteWebDriver

75

- **OperaDriverService**: Manages operadriver executable lifecycle

76

- **OperaOptions**: Configuration class for browser options and capabilities

77

- **OperaDriverInfo**: Metadata provider and driver factory

78

79

## Capabilities

80

81

### Driver Creation and Management

82

83

Core driver instantiation and lifecycle management.

84

85

```java { .api }

86

/**

87

* Main WebDriver implementation for Opera browser automation

88

*/

89

public class OperaDriver extends RemoteWebDriver

90

implements LocationContext, WebStorage {

91

92

// Default constructor with default service and options

93

public OperaDriver();

94

95

// Constructor with service

96

public OperaDriver(OperaDriverService service);

97

98

// Constructor with options (recommended)

99

public OperaDriver(OperaOptions options);

100

101

// Constructor with service and options

102

public OperaDriver(OperaDriverService service, OperaOptions options);

103

104

// Deprecated constructors with Capabilities

105

@Deprecated

106

public OperaDriver(Capabilities capabilities);

107

108

@Deprecated

109

public OperaDriver(OperaDriverService service, Capabilities capabilities);

110

}

111

```

112

113

### Browser Configuration

114

115

Configuration of Opera browser options, extensions, and startup parameters.

116

117

```java { .api }

118

/**

119

* Configuration options for Opera browser

120

*/

121

@Deprecated

122

public class OperaOptions extends AbstractDriverOptions<OperaOptions> {

123

124

public static final String CAPABILITY = "operaOptions";

125

126

// Constructor

127

public OperaOptions();

128

129

// Merge capabilities

130

public OperaOptions merge(Capabilities extraCapabilities);

131

132

// Set Opera binary path

133

public OperaOptions setBinary(File path);

134

public OperaOptions setBinary(String path);

135

136

// Add command line arguments

137

public OperaOptions addArguments(String... arguments);

138

public OperaOptions addArguments(List<String> arguments);

139

140

// Add extensions

141

public OperaOptions addExtensions(File... paths);

142

public OperaOptions addExtensions(List<File> paths);

143

public OperaOptions addEncodedExtensions(String... encoded);

144

public OperaOptions addEncodedExtensions(List<String> encoded);

145

146

// Experimental options

147

public OperaOptions setExperimentalOption(String name, Object value);

148

public Object getExperimentalOption(String name);

149

}

150

```

151

152

### Service Management

153

154

Management of operadriver server process and configuration.

155

156

```java { .api }

157

/**

158

* Manages operadriver server lifecycle

159

*/

160

public class OperaDriverService extends DriverService {

161

162

// System property constants

163

public static final String OPERA_DRIVER_EXE_PROPERTY = "webdriver.opera.driver";

164

public static final String OPERA_DRIVER_LOG_PROPERTY = "webdriver.opera.logfile";

165

public static final String OPERA_DRIVER_VERBOSE_LOG_PROPERTY = "webdriver.opera.verboseLogging";

166

public static final String OPERA_DRIVER_SILENT_OUTPUT_PROPERTY = "webdriver.opera.silentOutput";

167

168

// Constructors

169

public OperaDriverService(File executable, int port, List<String> args,

170

Map<String, String> environment) throws IOException;

171

172

public OperaDriverService(File executable, int port, Duration timeout,

173

List<String> args, Map<String, String> environment) throws IOException;

174

175

// Create default service

176

public static OperaDriverService createDefaultService();

177

}

178

179

/**

180

* Builder for OperaDriverService configuration

181

*/

182

@AutoService(DriverService.Builder.class)

183

public static class OperaDriverService.Builder

184

extends DriverService.Builder<OperaDriverService, OperaDriverService.Builder> {

185

186

// Configure verbosity

187

public Builder withVerbose(boolean verbose);

188

189

// Configure silent mode

190

public Builder withSilent(boolean silent);

191

192

// Score capabilities match

193

public int score(Capabilities capabilities);

194

195

// Create the service

196

protected OperaDriverService createDriverService(File exe, int port,

197

Duration timeout,

198

List<String> args,

199

Map<String, String> environment);

200

201

// Find default executable

202

protected File findDefaultExecutable();

203

204

// Create command line arguments

205

protected List<String> createArgs();

206

}

207

```

208

209

### Web Storage and Location

210

211

HTML5 web storage and geolocation capabilities.

212

213

```java { .api }

214

// OperaDriver implements these interfaces

215

216

/**

217

* Local and session storage access

218

*/

219

public interface WebStorage {

220

LocalStorage getLocalStorage();

221

SessionStorage getSessionStorage();

222

}

223

224

/**

225

* Geolocation capabilities

226

*/

227

public interface LocationContext {

228

Location location();

229

void setLocation(Location location);

230

}

231

232

// OperaDriver implementation methods

233

public LocalStorage getLocalStorage();

234

public SessionStorage getSessionStorage();

235

public Location location();

236

public void setLocation(Location location);

237

238

// File detector override (throws exception)

239

public void setFileDetector(FileDetector detector); // throws WebDriverException

240

```

241

242

### Driver Information

243

244

Metadata and factory methods for Opera driver discovery.

245

246

```java { .api }

247

/**

248

* Provides Opera driver metadata and factory methods

249

*/

250

@AutoService(WebDriverInfo.class)

251

public class OperaDriverInfo implements WebDriverInfo {

252

253

// Display name

254

public String getDisplayName(); // returns "Opera"

255

256

// Canonical capabilities

257

public Capabilities getCanonicalCapabilities();

258

259

// Support checks

260

public boolean isSupporting(Capabilities capabilities);

261

public boolean isSupportingCdp(); // returns false

262

public boolean isAvailable();

263

264

// Session limits

265

public int getMaximumSimultaneousSessions();

266

267

// Driver creation

268

public Optional<WebDriver> createDriver(Capabilities capabilities)

269

throws SessionNotCreatedException;

270

}

271

```

272

273

## Important Notes

274

275

**Deprecation Warning**: This entire package is deprecated because operadriver does not support W3C WebDriver standards. The recommended alternative is to use ChromeDriver with Opera binary path:

276

277

```java

278

import org.openqa.selenium.chrome.ChromeDriver;

279

import org.openqa.selenium.chrome.ChromeOptions;

280

281

ChromeOptions options = new ChromeOptions();

282

options.setBinary(new File("/path/to/opera"));

283

ChromeDriver driver = new ChromeDriver(options);

284

```

285

286

**System Properties**:

287

- `webdriver.opera.driver`: Path to operadriver executable

288

- `webdriver.opera.logfile`: Path to log file

289

- `webdriver.opera.verboseLogging`: Enable verbose logging (boolean)

290

- `webdriver.opera.silentOutput`: Enable silent mode (boolean)

291

292

**Required Dependencies**:

293

- operadriver executable must be available in PATH or specified via system property

294

- Selenium Remote WebDriver dependencies

295

- HTML5 support dependencies for LocationContext and WebStorage

296

297

## Types

298

299

```java { .api }

300

// Standard Selenium types used throughout the API

301

interface Capabilities {

302

Object getCapability(String capabilityName);

303

String getBrowserName();

304

Map<String, Object> asMap();

305

}

306

307

interface WebDriver {

308

void get(String url);

309

void quit();

310

// ... other WebDriver methods

311

}

312

313

// HTML5 support interfaces

314

interface LocationContext {

315

Location location();

316

void setLocation(Location location);

317

}

318

319

interface WebStorage {

320

LocalStorage getLocalStorage();

321

SessionStorage getSessionStorage();

322

}

323

324

// Service types

325

abstract class DriverService {

326

static Duration DEFAULT_TIMEOUT;

327

File getExecutable();

328

int getPort();

329

void start() throws IOException;

330

void stop();

331

}

332

333

abstract class DriverService.Builder<DS extends DriverService, B extends DriverService.Builder<?, ?>> {

334

B usingDriverExecutable(File file);

335

B usingAnyFreePort();

336

B usingPort(int port);

337

B withTimeout(Duration timeout);

338

B withLogFile(File logFile);

339

B withEnvironment(Map<String, String> environment);

340

DS build();

341

}

342

343

// File system types

344

class File {

345

File(String pathname);

346

String getPath();

347

String getAbsolutePath();

348

}

349

350

// Collection types

351

interface List<T> {

352

boolean add(T element);

353

boolean addAll(Collection<? extends T> elements);

354

}

355

356

interface Map<K, V> {

357

V put(K key, V value);

358

V get(K key);

359

}

360

361

// HTML5 storage interfaces

362

interface LocalStorage {

363

void setItem(String key, String value);

364

String getItem(String key);

365

void removeItem(String key);

366

}

367

368

interface SessionStorage {

369

void setItem(String key, String value);

370

String getItem(String key);

371

void removeItem(String key);

372

}

373

374

interface Location {

375

double getLatitude();

376

double getLongitude();

377

double getAltitude();

378

}

379

380

// Exception types

381

class IOException extends Exception {}

382

class WebDriverException extends RuntimeException {}

383

class SessionNotCreatedException extends WebDriverException {}

384

class IllegalStateException extends RuntimeException {}

385

386

// Annotation types

387

@interface AutoService {

388

Class<?>[] value();

389

}

390

391

@interface Deprecated {}

392

393

// Utility types

394

class Duration {

395

static Duration ofSeconds(long seconds);

396

}

397

398

class Optional<T> {

399

static <T> Optional<T> empty();

400

static <T> Optional<T> of(T value);

401

boolean isPresent();

402

T get();

403

}

404

```