selenium-webdriver 4.28.1 → 4.29.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/CHANGES.md +9 -2
- package/bidi/browser.js +17 -0
- package/bidi/clientWindowInfo.js +54 -0
- package/bidi/network.js +40 -1
- package/bin/linux/selenium-manager +0 -0
- package/bin/macos/selenium-manager +0 -0
- package/bin/windows/selenium-manager.exe +0 -0
- package/lib/network.js +2 -2
- package/lib/webdriver.js +2 -8
- package/package.json +1 -1
package/CHANGES.md
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
|
+
## 4.29.0
|
|
2
|
+
|
|
3
|
+
- Add CDP for Chrome 133 and remove 130
|
|
4
|
+
- [js] Remove Firefox CDP (#15200)
|
|
5
|
+
- [js][bidi] Implement bidi `setCacheBehavior` command (#15136)
|
|
6
|
+
- [js][bidi] Implement bidi getClientWindows command in browser module (#15248)
|
|
7
|
+
|
|
1
8
|
## 4.28.1
|
|
2
|
-
|
|
3
|
-
|
|
9
|
+
|
|
10
|
+
- [JS] specify min required node versiton to 18.20.5
|
|
4
11
|
|
|
5
12
|
## 4.28.0
|
|
6
13
|
|
package/bidi/browser.js
CHANGED
|
@@ -15,6 +15,8 @@
|
|
|
15
15
|
// specific language governing permissions and limitations
|
|
16
16
|
// under the License.
|
|
17
17
|
|
|
18
|
+
const { WindowState, ClientWindowInfo } = require('./clientWindowInfo')
|
|
19
|
+
|
|
18
20
|
/**
|
|
19
21
|
* Represents the commands and events under Browser Module.
|
|
20
22
|
* Described in https://w3c.github.io/webdriver-bidi/#module-browser
|
|
@@ -83,6 +85,20 @@ class Browser {
|
|
|
83
85
|
|
|
84
86
|
await this.bidi.send(command)
|
|
85
87
|
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Gets information about all client windows.
|
|
91
|
+
* @returns {Promise<ClientWindowInfo[]>} Array of client window information
|
|
92
|
+
*/
|
|
93
|
+
async getClientWindows() {
|
|
94
|
+
const command = {
|
|
95
|
+
method: 'browser.getClientWindows',
|
|
96
|
+
params: {},
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
const response = await this.bidi.send(command)
|
|
100
|
+
return response.result.clientWindows.map((window) => ClientWindowInfo.fromJson(window))
|
|
101
|
+
}
|
|
86
102
|
}
|
|
87
103
|
|
|
88
104
|
async function getBrowserInstance(driver) {
|
|
@@ -92,3 +108,4 @@ async function getBrowserInstance(driver) {
|
|
|
92
108
|
}
|
|
93
109
|
|
|
94
110
|
module.exports = getBrowserInstance
|
|
111
|
+
module.exports.WindowState = WindowState
|
|
@@ -0,0 +1,54 @@
|
|
|
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
|
+
const WindowState = Object.freeze({
|
|
19
|
+
FULLSCREEN: 'fullscreen',
|
|
20
|
+
MAXIMIZED: 'maximized',
|
|
21
|
+
MINIMIZED: 'minimized',
|
|
22
|
+
NORMAL: 'normal',
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
class ClientWindowInfo {
|
|
26
|
+
/**
|
|
27
|
+
* @param {Object} params Window information parameters
|
|
28
|
+
* @param {string} params.clientWindow Window identifier
|
|
29
|
+
* @param {string} params.state Window state from WindowState
|
|
30
|
+
* @param {number} params.width Window width
|
|
31
|
+
* @param {number} params.height Window height
|
|
32
|
+
* @param {number} params.x Window x coordinate
|
|
33
|
+
* @param {number} params.y Window y coordinate
|
|
34
|
+
* @param {boolean} params.active Whether window is active and can receive keyboard input
|
|
35
|
+
*/
|
|
36
|
+
constructor({ clientWindow, state, width, height, x, y, active }) {
|
|
37
|
+
this.clientWindow = clientWindow
|
|
38
|
+
this.state = state
|
|
39
|
+
this.width = width
|
|
40
|
+
this.height = height
|
|
41
|
+
this.x = x
|
|
42
|
+
this.y = y
|
|
43
|
+
this.active = active
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
static fromJson(json) {
|
|
47
|
+
return new ClientWindowInfo({
|
|
48
|
+
...json,
|
|
49
|
+
state: json.state.toLowerCase(),
|
|
50
|
+
})
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
module.exports = { WindowState, ClientWindowInfo }
|
package/bidi/network.js
CHANGED
|
@@ -29,6 +29,11 @@ const NetworkEvent = {
|
|
|
29
29
|
FETCH_ERROR: 'network.fetchError',
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
+
const CacheBehavior = Object.freeze({
|
|
33
|
+
DEFAULT: 'default',
|
|
34
|
+
BYPASS: 'bypass',
|
|
35
|
+
})
|
|
36
|
+
|
|
32
37
|
/**
|
|
33
38
|
* Represents all commands and events of Network module.
|
|
34
39
|
* Described in https://w3c.github.io/webdriver-bidi/#module-network.
|
|
@@ -355,6 +360,40 @@ class Network {
|
|
|
355
360
|
await this.bidi.send(command)
|
|
356
361
|
}
|
|
357
362
|
|
|
363
|
+
/**
|
|
364
|
+
* Sets the cache behavior for network requests.
|
|
365
|
+
*
|
|
366
|
+
* @param {string} behavior - The cache behavior ("default" or "bypass")
|
|
367
|
+
* @param {Array<string>} [contexts] - Optional array of browsing context IDs
|
|
368
|
+
* @returns {Promise<void>} A promise that resolves when the cache behavior is set
|
|
369
|
+
* @throws {Error} If behavior is invalid or context IDs are invalid
|
|
370
|
+
*/
|
|
371
|
+
async setCacheBehavior(behavior, contexts = null) {
|
|
372
|
+
if (!Object.values(CacheBehavior).includes(behavior)) {
|
|
373
|
+
throw new Error(`Cache behavior must be either "${CacheBehavior.DEFAULT}" or "${CacheBehavior.BYPASS}"`)
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
const command = {
|
|
377
|
+
method: 'network.setCacheBehavior',
|
|
378
|
+
params: {
|
|
379
|
+
cacheBehavior: behavior,
|
|
380
|
+
},
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
if (contexts !== null) {
|
|
384
|
+
if (
|
|
385
|
+
!Array.isArray(contexts) ||
|
|
386
|
+
contexts.length === 0 ||
|
|
387
|
+
contexts.some((c) => typeof c !== 'string' || c.trim() === '')
|
|
388
|
+
) {
|
|
389
|
+
throw new Error('Contexts must be an array of non-empty strings')
|
|
390
|
+
}
|
|
391
|
+
command.params.contexts = contexts
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
await this.bidi.send(command)
|
|
395
|
+
}
|
|
396
|
+
|
|
358
397
|
/**
|
|
359
398
|
* Unsubscribes from network events for all browsing contexts.
|
|
360
399
|
* @returns {Promise<void>} A promise that resolves when the network connection is closed.
|
|
@@ -389,4 +428,4 @@ async function getNetworkInstance(driver, browsingContextIds = null) {
|
|
|
389
428
|
return instance
|
|
390
429
|
}
|
|
391
430
|
|
|
392
|
-
module.exports = getNetworkInstance
|
|
431
|
+
module.exports = { Network: getNetworkInstance, CacheBehavior }
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/lib/network.js
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
// specific language governing permissions and limitations
|
|
16
16
|
// under the License.
|
|
17
17
|
|
|
18
|
-
const
|
|
18
|
+
const { Network: getNetwork } = require('../bidi/network')
|
|
19
19
|
const { InterceptPhase } = require('../bidi/interceptPhase')
|
|
20
20
|
const { AddInterceptParameters } = require('../bidi/addInterceptParameters')
|
|
21
21
|
|
|
@@ -39,7 +39,7 @@ class Network {
|
|
|
39
39
|
if (this.#network !== undefined) {
|
|
40
40
|
return
|
|
41
41
|
}
|
|
42
|
-
this.#network = await
|
|
42
|
+
this.#network = await getNetwork(this.#driver)
|
|
43
43
|
|
|
44
44
|
await this.#network.addIntercept(new AddInterceptParameters(InterceptPhase.AUTH_REQUIRED))
|
|
45
45
|
|
package/lib/webdriver.js
CHANGED
|
@@ -1244,9 +1244,7 @@ class WebDriver {
|
|
|
1244
1244
|
const caps = await this.getCapabilities()
|
|
1245
1245
|
|
|
1246
1246
|
if (caps['map_'].get('browserName') === 'firefox') {
|
|
1247
|
-
|
|
1248
|
-
'CDP support for Firefox is deprecated and will be removed in future versions. Please switch to WebDriver BiDi.',
|
|
1249
|
-
)
|
|
1247
|
+
throw new Error('CDP support for Firefox is removed. Please switch to WebDriver BiDi.')
|
|
1250
1248
|
}
|
|
1251
1249
|
|
|
1252
1250
|
if (process.env.SELENIUM_REMOTE_URL) {
|
|
@@ -1255,11 +1253,7 @@ class WebDriver {
|
|
|
1255
1253
|
debuggerUrl = `ws://${host}/session/${sessionId}/se/cdp`
|
|
1256
1254
|
} else {
|
|
1257
1255
|
const seCdp = caps['map_'].get('se:cdp')
|
|
1258
|
-
const vendorInfo =
|
|
1259
|
-
caps['map_'].get('goog:chromeOptions') ||
|
|
1260
|
-
caps['map_'].get('ms:edgeOptions') ||
|
|
1261
|
-
caps['map_'].get('moz:debuggerAddress') ||
|
|
1262
|
-
new Map()
|
|
1256
|
+
const vendorInfo = caps['map_'].get('goog:chromeOptions') || caps['map_'].get('ms:edgeOptions') || new Map()
|
|
1263
1257
|
debuggerUrl = seCdp || vendorInfo['debuggerAddress'] || vendorInfo
|
|
1264
1258
|
}
|
|
1265
1259
|
this._wsUrl = await this.getWsUrl(debuggerUrl, target, caps)
|