Skip to content

Commit 84b65b1

Browse files
[JS] Remove support for Edge HTML (#9239)
* [js] Removes support for edge legacy * [js] Adding edge chromium test * Modify: Replacing VENDOR_CAPABILITY_PREFIX prototype in chrome and edge Co-authored-by: David Burns <david.burns@theautomatedtester.co.uk>
1 parent 6e44d37 commit 84b65b1

5 files changed

Lines changed: 140 additions & 141 deletions

File tree

javascript/node/selenium-webdriver/CHANGES.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## v4.0.0-beta.2
2+
3+
* Removed support for Edge legacy.
4+
15
## v4.0.0-beta.1
26

37
* JS Binding support for WebDriver Bidi in Firefox

javascript/node/selenium-webdriver/edge.js

Lines changed: 89 additions & 135 deletions
Original file line numberDiff line numberDiff line change
@@ -17,28 +17,19 @@
1717

1818
/**
1919
* @fileoverview Defines a {@linkplain Driver WebDriver} client for
20-
* Microsoft's Edge web browser. Both Edge (Chromium), and Edge Legacy (EdgeHTML) are
21-
* supported. Before using this module, you must download and install the correct
22-
* [WebDriver](https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/)
23-
* server.
20+
* Microsoft's Edge web browser. Edge (Chromium) is supported and support
21+
* for Edge Legacy (EdgeHTML) as part of https://github.com/SeleniumHQ/selenium/issues/9166.
22+
* Before using this module, you must download and install the correct
23+
* [WebDriver](https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/) server.
2424
*
25-
* Ensure that the either MicrosoftWebDriver (EdgeHTML) or msedgedriver (Chromium)
26-
* is on your [PATH](http://en.wikipedia.org/wiki/PATH_%28variable%29). MicrosoftWebDriver
27-
* and Edge Legacy (EdgeHTML) will be used by default.
25+
* Ensure that the msedgedriver (Chromium)
26+
* is on your [PATH](http://en.wikipedia.org/wiki/PATH_%28variable%29).
2827
*
29-
* You may use {@link Options} to specify whether Edge Chromium should be used:
28+
* You may use {@link Options} to specify whether Edge Chromium options should be used:
3029
31-
* var edge = require('selenium-webdriver/edge');
32-
* var options = new edge.Options();
33-
* options.setEdgeChromium(true);
34-
* // configure browser options ...
35-
* let driver = await new Builder()
36-
* .forBrowser('MicrosoftEdge')
37-
* .setEdgeOptions(options)
38-
* .build();
30+
* const edge = require('selenium-webdriver/edge');
31+
* const options = new edge.Options();
3932
40-
* Note that Chromium-specific {@link Options} will be ignored when using Edge Legacy.
41-
*
4233
* There are three primary classes exported by this module:
4334
*
4435
* 1. {@linkplain ServiceBuilder}: configures the
@@ -65,134 +56,121 @@
6556
* You may also create a {@link Driver} with its own driver service. This is
6657
* useful if you need to capture the server's log output for a specific session:
6758
*
68-
* var edge = require('selenium-webdriver/edge');
59+
* const edge = require('selenium-webdriver/edge');
6960
*
70-
* var service = new edge.ServiceBuilder()
61+
* const service = new edge.ServiceBuilder()
7162
* .setPort(55555)
7263
* .build();
7364
*
74-
* var options = new edge.Options();
65+
* let options = new edge.Options();
7566
* // configure browser options ...
7667
*
77-
* var driver = edge.Driver.createSession(options, service);
68+
* let driver = edge.Driver.createSession(options, service);
7869
*
7970
* Users should only instantiate the {@link Driver} class directly when they
8071
* need a custom driver service configuration (as shown above). For normal
81-
* operation, users should start MicrosoftEdge using the
72+
* operation, users should start msedgedriver using the
8273
* {@link ./builder.Builder selenium-webdriver.Builder}.
8374
*
84-
* [WebDriver (EdgeHTML)]: https://docs.microsoft.com/en-us/microsoft-edge/webdriver
8575
* [WebDriver (Chromium)]: https://docs.microsoft.com/en-us/microsoft-edge/webdriver-chromium
8676
*/
8777

8878
'use strict'
8979

90-
const http = require('./http')
80+
const { Browser } = require('./lib/capabilities')
9181
const io = require('./io')
92-
const webdriver = require('./lib/webdriver')
93-
const { Browser, Capabilities } = require('./lib/capabilities')
9482
const chromium = require('./chromium')
83+
const http = require('./http')
84+
const webdriver = require('./lib/webdriver')
9585

96-
const EDGE_CHROMIUM_BROWSER_NAME = 'msedge'
97-
const EDGEDRIVER_LEGACY_EXE = 'MicrosoftWebDriver.exe'
86+
/**
87+
* Name of the EdgeDriver executable.
88+
* @type {string}
89+
* @const
90+
*/
9891
const EDGEDRIVER_CHROMIUM_EXE =
9992
process.platform === 'win32' ? 'msedgedriver.exe' : 'msedgedriver'
10093

94+
/** @type {remote.DriverService} */
95+
let defaultService = null
96+
10197
/**
102-
* _Synchronously_ attempts to locate the Edge driver executable
103-
* on the current system. Searches for the legacy MicrosoftWebDriver by default.
104-
*
105-
* @param {string=} browserName Name of the Edge driver executable to locate.
106-
* May be either 'msedge' to locate the Edge Chromium driver, or 'MicrosoftEdge' to
107-
* locate the Edge Legacy driver. If omitted, will attempt to locate Edge Legacy.
108-
* @return {?string} the located executable, or `null`.
98+
* Creates {@link selenium-webdriver/remote.DriverService} instances that manage
99+
* a [ChromeDriver](https://chromedriver.chromium.org/)
100+
* server in a child process.
109101
*/
110-
function locateSynchronously(browserName) {
111-
browserName = browserName || Browser.EDGE
112-
113-
if (browserName === EDGE_CHROMIUM_BROWSER_NAME) {
114-
return io.findInPath(EDGEDRIVER_CHROMIUM_EXE, true)
102+
class ServiceBuilder extends chromium.ServiceBuilder {
103+
/**
104+
* @param {string=} opt_exe Path to the server executable to use. If omitted,
105+
* the builder will attempt to locate the msedgedriver on the current
106+
* PATH.
107+
* @throws {Error} If provided executable does not exist, or the msedgedriver
108+
* cannot be found on the PATH.
109+
*/
110+
constructor(opt_exe) {
111+
let exe = opt_exe || locateSynchronously()
112+
if (!exe) {
113+
throw Error(
114+
`The WebDriver for Edge could not be found on the current PATH. Please download the `+
115+
`latest version of ${EDGEDRIVER_CHROMIUM_EXE} from `+
116+
`https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/ `+
117+
`and ensure it can be found on your PATH.`
118+
)
119+
}
120+
super(exe)
121+
this.setLoopback(true)
115122
}
116-
117-
return process.platform === 'win32'
118-
? io.findInPath(EDGEDRIVER_LEGACY_EXE, true)
119-
: null
120123
}
121124

122125
/**
123-
* Class for managing Edge specific options.
126+
* Class for managing edge chromium specific options.
124127
*/
125128
class Options extends chromium.Options {
126129
/**
127-
* Instruct the EdgeDriver to use Edge Chromium if true.
128-
* Otherwise, use Edge Legacy (EdgeHTML). Defaults to using Edge Legacy.
130+
* Sets the path to the edge binary to use
131+
*
132+
* The binary path be absolute or relative to the msedgedriver server
133+
* executable, but it must exist on the machine that will launch edge chromium.
129134
*
130-
* @param {boolean} useEdgeChromium
135+
* @param {string} path The path to the edgedriver binary to use.
131136
* @return {!Options} A self reference.
132137
*/
133-
setEdgeChromium(useEdgeChromium) {
134-
this.set(Options.USE_EDGE_CHROMIUM, !!useEdgeChromium)
135-
return this
138+
setEdgeChromiumBinaryPath(path) {
139+
return this.setBinaryPath(path)
136140
}
137141
}
138142

139-
Options.USE_EDGE_CHROMIUM = 'ms:edgeChromium'
140-
Options.prototype.BROWSER_NAME_VALUE = Browser.EDGE
141-
Options.prototype.CAPABILITY_KEY = 'ms:edgeOptions'
142-
Options.prototype.VENDOR_CAPABILITY_PREFIX = 'ms'
143-
144143
/**
145-
* @param {(Capabilities|Object<string, *>)=} o The options object
146-
* @return {boolean}
144+
* Creates a new WebDriver client for Microsoft's Edge.
147145
*/
148-
function useEdgeChromium(o) {
149-
if (o instanceof Capabilities) {
150-
return !!o.get(Options.USE_EDGE_CHROMIUM)
151-
}
146+
class Driver extends webdriver.WebDriver {
147+
/**
148+
* Creates a new browser session for Microsoft's Edge browser.
149+
*
150+
* @param {(Capabilities|Options)=} options The configuration options.
151+
* @param {remote.DriverService=} opt_service The service to use; will create
152+
* a new Legacy or Chromium service based on {@linkplain Options} by default.
153+
* @return {!Driver} A new driver instance.
154+
*/
155+
static createSession(options, opt_service) {
156+
options = options || new Options()
157+
let service = opt_service || getDefaultService()
158+
let client = service.start().then((url) => new http.HttpClient(url))
159+
let executor = new http.Executor(client)
152160

153-
if (o && typeof o === 'object') {
154-
return !!o[Options.USE_EDGE_CHROMIUM]
161+
return /** @type {!Driver} */ (super.createSession(executor, options, () =>
162+
service.kill()
163+
))
155164
}
156165

157-
return false
158-
}
159-
160-
/**
161-
* Creates {@link remote.DriverService} instances that manage a
162-
* WebDriver server in a child process. Used for driving both
163-
* Microsoft Edge Legacy and Chromium. A ServiceBuilder constructed
164-
* with default parameters will launch a MicrosoftWebDriver child
165-
* process for driving Edge Legacy. You may pass in a path to
166-
* msedgedriver.exe to use Edge Chromium instead.
167-
*/
168-
class ServiceBuilder extends chromium.ServiceBuilder {
169166
/**
170-
* @param {string=} opt_exe Path to the server executable to use. If omitted,
171-
* the builder will attempt to locate MicrosoftWebDriver on the current
172-
* PATH.
173-
* @throws {Error} If provided executable does not exist, or the
174-
* MicrosoftWebDriver cannot be found on the PATH.
167+
* This function is a no-op as file detectors are not supported by this
168+
* implementation.
169+
* @override
175170
*/
176-
constructor(opt_exe) {
177-
const exe = opt_exe || locateSynchronously()
178-
if (!exe) {
179-
throw Error(
180-
'The WebDriver for Edge could not be found on the current PATH. Please ' +
181-
'download the latest version of ' +
182-
EDGEDRIVER_LEGACY_EXE +
183-
' from ' +
184-
'https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/ and ' +
185-
'ensure it can be found on your PATH.'
186-
)
187-
}
188-
189-
super(exe)
190-
}
171+
setFileDetector() {}
191172
}
192173

193-
/** @type {remote.DriverService} */
194-
var defaultService = null
195-
196174
/**
197175
* Sets the default service to use for new Edge instances.
198176
* @param {!remote.DriverService} service The service to use.
@@ -202,7 +180,7 @@ function setDefaultService(service) {
202180
if (defaultService && defaultService.isRunning()) {
203181
throw Error(
204182
'The previously configured EdgeDriver service is still running. ' +
205-
'You must shut it down before you may adjust its configuration.'
183+
'You must shut it down before you may adjust its configuration.'
206184
)
207185
}
208186
defaultService = service
@@ -221,45 +199,21 @@ function getDefaultService() {
221199
return defaultService
222200
}
223201

224-
function createServiceFromCapabilities(options) {
225-
let exe
226-
if (useEdgeChromium(options)) {
227-
exe = locateSynchronously(EDGE_CHROMIUM_BROWSER_NAME)
228-
}
229-
return new ServiceBuilder(exe).build()
230-
}
231202

232203
/**
233-
* Creates a new WebDriver client for Microsoft's Edge.
204+
* _Synchronously_ attempts to locate the chromedriver executable on the current
205+
* system.
206+
*
207+
* @return {?string} the located executable, or `null`.
234208
*/
235-
class Driver extends webdriver.WebDriver {
236-
/**
237-
* Creates a new browser session for Microsoft's Edge browser.
238-
*
239-
* @param {(Capabilities|Options)=} options The configuration options.
240-
* @param {remote.DriverService=} opt_service The service to use; will create
241-
* a new Legacy or Chromium service based on {@linkplain Options} by default.
242-
* @return {!Driver} A new driver instance.
243-
*/
244-
static createSession(options, opt_service) {
245-
options = options || new Options()
246-
let service = opt_service || createServiceFromCapabilities(options)
247-
let client = service.start().then((url) => new http.HttpClient(url))
248-
let executor = new http.Executor(client)
249-
250-
return /** @type {!Driver} */ (super.createSession(executor, options, () =>
251-
service.kill()
252-
))
253-
}
254-
255-
/**
256-
* This function is a no-op as file detectors are not supported by this
257-
* implementation.
258-
* @override
259-
*/
260-
setFileDetector() {}
209+
function locateSynchronously() {
210+
return io.findInPath(EDGEDRIVER_CHROMIUM_EXE, true)
261211
}
262212

213+
Options.prototype.BROWSER_NAME_VALUE = Browser.EDGE
214+
Options.prototype.CAPABILITY_KEY = 'ms:edgeOptions'
215+
Driver.prototype.VENDOR_CAPABILITY_PREFIX = 'ms'
216+
263217
// PUBLIC API
264218

265219
exports.Driver = Driver

javascript/node/selenium-webdriver/lib/webdriver.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -649,6 +649,7 @@ function filterNonW3CCaps(capabilities) {
649649
* @implements {IWebDriver}
650650
*/
651651
class WebDriver {
652+
652653
/**
653654
* @param {!(./session.Session|IThenable<!./session.Session>)} session Either
654655
* a known session or a promise that will be resolved to a session.
@@ -1163,8 +1164,9 @@ class WebDriver {
11631164
const seCdp = caps['map_'].get('se:cdp')
11641165
const vendorInfo =
11651166
caps['map_'].get(this.VENDOR_COMMAND_PREFIX + ':chromeOptions') ||
1167+
caps['map_'].get(this.VENDOR_CAPABILITY_PREFIX + ':edgeOptions') ||
11661168
caps['map_'].get('moz:debuggerAddress') ||
1167-
new Map()
1169+
new Map();
11681170
const debuggerUrl = seCdp || vendorInfo['debuggerAddress'] || vendorInfo
11691171
this._wsUrl = await this.getWsUrl(debuggerUrl, target)
11701172

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
// Licensed to the Software Freedom Conservancy (SFC) under one
2+
// or more contributor license agreements. See the NOTICE file
3+
// distributed with this work for additional information
4+
// regarding copyright ownership. The SFC licenses this file
5+
// to you under the Apache License, Version 2.0 (the
6+
// "License"); you may not use this file except in compliance
7+
// with the License. You may obtain a copy of the License at
8+
//
9+
// http://www.apache.org/licenses/LICENSE-2.0
10+
//
11+
// Unless required by applicable law or agreed to in writing,
12+
// software distributed under the License is distributed on an
13+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
// KIND, either express or implied. See the License for the
15+
// specific language governing permissions and limitations
16+
// under the License.
17+
18+
'use strict'
19+
20+
const assert = require('assert')
21+
const edge = require('../edge')
22+
const test = require('../lib/test')
23+
24+
test.suite(
25+
function (_env) {
26+
describe('msedgedriver', function () {
27+
let service
28+
29+
afterEach(function () {
30+
if (service) {
31+
return service.kill()
32+
}
33+
})
34+
35+
it('can start msedgedriver', async function () {
36+
service = new edge.ServiceBuilder().build()
37+
38+
let url = await service.start()
39+
assert(/127\.0\.0\.1/.test(url), `unexpected url: ${url}`)
40+
})
41+
})
42+
},
43+
{ browsers: ['MicrosoftEdge'] }
44+
)

javascript/node/selenium-webdriver/testing/index.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -120,11 +120,6 @@ function getAvailableBrowsers() {
120120
let targets = [
121121
[chrome.locateSynchronously, Browser.CHROME],
122122
[edge.locateSynchronously, Browser.EDGE],
123-
[
124-
() => edge.locateSynchronously('msedge'),
125-
Browser.EDGE,
126-
{ 'ms:edgeChromium': true },
127-
],
128123
[firefox.locateSynchronously, Browser.FIREFOX],
129124
[ie.locateSynchronously, Browser.INTERNET_EXPLORER],
130125
[safari.locateSynchronously, Browser.SAFARI],

0 commit comments

Comments
 (0)