webdriver-installer 1.2.1 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,40 @@
1
1
  # Changelog
2
2
 
3
+ ## [1.3.0](https://github.com/shaka-project/webdriver-installer/compare/v1.2.5...v1.3.0) (2026-01-26)
4
+
5
+
6
+ ### Features
7
+
8
+ * Add Opera support ([#61](https://github.com/shaka-project/webdriver-installer/issues/61)) ([e242054](https://github.com/shaka-project/webdriver-installer/commit/e242054106996d2f2d0078964dedac6d6c4caf73))
9
+
10
+ ## [1.2.5](https://github.com/shaka-project/webdriver-installer/compare/v1.2.4...v1.2.5) (2025-12-16)
11
+
12
+
13
+ ### Bug Fixes
14
+
15
+ * **ci:** Fixed typo in NPM config ([a052388](https://github.com/shaka-project/webdriver-installer/commit/a052388f6ea4c6997c67a75418fa900b851a8ed3))
16
+
17
+ ## [1.2.4](https://github.com/shaka-project/webdriver-installer/compare/v1.2.3...v1.2.4) (2025-12-16)
18
+
19
+
20
+ ### Bug Fixes
21
+
22
+ * **ci:** Trusted publishing works now ([#57](https://github.com/shaka-project/webdriver-installer/issues/57)) ([2d42fad](https://github.com/shaka-project/webdriver-installer/commit/2d42fad9bd1f64874e61227cee1b7ad4a2cb68a4))
23
+
24
+ ## [1.2.3](https://github.com/shaka-project/webdriver-installer/compare/v1.2.2...v1.2.3) (2025-10-03)
25
+
26
+
27
+ ### Bug Fixes
28
+
29
+ * **ci:** Update npm to support OIDC for trusted publishing ([#55](https://github.com/shaka-project/webdriver-installer/issues/55)) ([e95d0a2](https://github.com/shaka-project/webdriver-installer/commit/e95d0a27b1d4c251d70b5aaa0b9d05f978ef4b4b))
30
+
31
+ ## [1.2.2](https://github.com/shaka-project/webdriver-installer/compare/v1.2.1...v1.2.2) (2025-10-03)
32
+
33
+
34
+ ### Bug Fixes
35
+
36
+ * **ci:** Stop using NPM token, use trusted publishing ([#53](https://github.com/shaka-project/webdriver-installer/issues/53)) ([1c39ef4](https://github.com/shaka-project/webdriver-installer/commit/1c39ef49834fc6372dc2384739990d599a450eff))
37
+
3
38
  ## [1.2.1](https://github.com/shaka-project/webdriver-installer/compare/v1.2.0...v1.2.1) (2025-07-16)
4
39
 
5
40
 
package/main.js CHANGED
@@ -9,12 +9,14 @@ const {ChromeWebDriverInstaller} = require('./chrome.js');
9
9
  const {ChromeAndroidWebDriverInstaller} = require('./chrome-android.js');
10
10
  const {FirefoxWebDriverInstaller} = require('./firefox.js');
11
11
  const {EdgeWebDriverInstaller} = require('./edge.js');
12
+ const {OperaWebDriverInstaller} = require('./opera.js');
12
13
 
13
14
  const INSTALLER_CLASSES = [
14
15
  ChromeWebDriverInstaller,
15
16
  ChromeAndroidWebDriverInstaller,
16
17
  FirefoxWebDriverInstaller,
17
18
  EdgeWebDriverInstaller,
19
+ OperaWebDriverInstaller,
18
20
  ];
19
21
 
20
22
  /**
package/opera.js ADDED
@@ -0,0 +1,143 @@
1
+ /*! @license
2
+ * WebDriver Installer
3
+ * Copyright 2022 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+
7
+ const {WebDriverInstallerBase} = require('./base.js');
8
+ const {InstallerUtils} = require('./utils.js');
9
+
10
+ const os = require('os');
11
+ const path = require('path');
12
+
13
+ class OperaWebDriverInstaller extends WebDriverInstallerBase {
14
+ getBrowserName() {
15
+ return 'Opera';
16
+ }
17
+
18
+ getDriverName() {
19
+ return 'operadriver';
20
+ }
21
+
22
+ /**
23
+ * Get installed Opera browser version.
24
+ * Handles macOS, Linux (including Snap), and Windows.
25
+ */
26
+ async getInstalledBrowserVersion() {
27
+ if (os.platform() === 'darwin') {
28
+ // Try common macOS bundle names
29
+ return (
30
+ await InstallerUtils.getMacAppVersion('Opera') ||
31
+ await InstallerUtils.getMacAppVersion('Opera Stable')
32
+ );
33
+ }
34
+
35
+ if (os.platform() === 'linux') {
36
+ // Try Snap installation first
37
+ let version = await InstallerUtils.getCommandOutputOrNullIfMissing(
38
+ ['/snap/bin/opera', '--version']
39
+ );
40
+ if (!version) {
41
+ // Fallback to PATH
42
+ version = await InstallerUtils.getCommandOutputOrNullIfMissing(
43
+ ['opera', '--version']
44
+ );
45
+ }
46
+ // return only version number
47
+ return version ? version.trim().split(' ')[0] : null;
48
+ }
49
+
50
+ if (os.platform() === 'win32') {
51
+ // Try standard paths
52
+ const possiblePaths = [
53
+ 'C:\\Program Files\\Opera\\opera.exe',
54
+ 'C:\\Program Files (x86)\\Opera\\opera.exe',
55
+ 'C:\\Users\\' + os.userInfo().username + '\\AppData\\Local\\Programs\\Opera\\opera.exe',
56
+ ];
57
+
58
+ for (const exePath of possiblePaths) {
59
+ const version = await InstallerUtils.getWindowsExeVersion(exePath);
60
+ if (version) {
61
+ return version;
62
+ }
63
+ }
64
+
65
+ // Fallback to PATH
66
+ return await InstallerUtils.getWindowsExeVersion('opera.exe');
67
+ }
68
+
69
+ throw new Error(`Unsupported platform: ${os.platform()}`);
70
+ }
71
+
72
+ /**
73
+ * Get installed OperaDriver version from output directory.
74
+ */
75
+ async getInstalledDriverVersion(outputDirectory) {
76
+ let outputPath = path.join(outputDirectory, this.getDriverName());
77
+ if (os.platform() === 'win32') {
78
+ outputPath += '.exe';
79
+ }
80
+
81
+ const output = await InstallerUtils.getCommandOutputOrNullIfMissing(
82
+ [outputPath, '--version']
83
+ );
84
+ // Example: "operadriver 114.0.5735.90 (...)"
85
+ return output ? output.trim().split(' ')[1] : null;
86
+ }
87
+
88
+ /**
89
+ * Always fetch the latest OperaDriver release from GitHub.
90
+ * This avoids 404 errors if the installed Opera version
91
+ * does not have a matching driver.
92
+ */
93
+ async getBestDriverVersion(_browserVersion) {
94
+ const tag = await InstallerUtils.fetchLatestGitHubTag(
95
+ 'operasoftware/operachromiumdriver'
96
+ );
97
+
98
+ // tag example: "v114.0.5735.90"
99
+ return tag.replace(/^v\.?/, '');
100
+ }
101
+
102
+ /**
103
+ * Install the OperaDriver binary for the current platform.
104
+ */
105
+ async install(driverVersion, outputDirectory) {
106
+ let platform;
107
+ let binaryName = 'operadriver';
108
+
109
+ if (os.platform() === 'linux') {
110
+ platform = 'linux64';
111
+ } else if (os.platform() === 'darwin') {
112
+ platform = 'mac64';
113
+ } else if (os.platform() === 'win32') {
114
+ platform = 'win64';
115
+ binaryName += '.exe';
116
+ } else {
117
+ throw new Error(`Unsupported platform: ${os.platform()}`);
118
+ }
119
+
120
+ const archiveUrl =
121
+ `https://github.com/operasoftware/operachromiumdriver/releases/download/` +
122
+ `v.${driverVersion}/operadriver_${platform}.zip`;
123
+
124
+ // IMPORTANT: operadriver is inside a folder in the zip
125
+ const nameInArchive = `operadriver_${platform}/${binaryName}`;
126
+
127
+ let outputName = this.getDriverName();
128
+ if (os.platform() === 'win32') {
129
+ outputName += '.exe';
130
+ }
131
+
132
+ // Install binary from network archive
133
+ return InstallerUtils.installBinary(
134
+ archiveUrl,
135
+ nameInArchive,
136
+ outputName,
137
+ outputDirectory,
138
+ /* isZip */ true
139
+ );
140
+ }
141
+ }
142
+
143
+ module.exports = {OperaWebDriverInstaller};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "webdriver-installer",
3
- "version": "1.2.1",
3
+ "version": "1.3.0",
4
4
  "description": "Install the right WebDriver version for your local browsers, automatically.",
5
5
  "main": "main.js",
6
6
  "bin": {
@@ -14,7 +14,8 @@
14
14
  "webdriver",
15
15
  "chrome",
16
16
  "firefox",
17
- "edge"
17
+ "edge",
18
+ "opera"
18
19
  ],
19
20
  "author": "Joey Parrish <joeyparrish@google.com>",
20
21
  "dependencies": {