selenium-webdriver 4.19.0 → 4.20.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 +15 -0
- package/bidi/addInterceptParameters.js +28 -2
- package/bidi/browser.js +17 -0
- package/bidi/browsingContext.js +207 -25
- package/bidi/browsingContextInspector.js +51 -0
- package/bidi/browsingContextTypes.js +31 -0
- package/bidi/captureScreenshotParameters.js +96 -0
- package/bidi/clipRectangle.js +127 -0
- package/bidi/continueRequestParameters.js +39 -0
- package/bidi/continueResponseParameters.js +40 -0
- package/bidi/cookieFilter.js +60 -0
- package/bidi/createContextParameters.js +73 -0
- package/bidi/evaluateResult.js +17 -0
- package/bidi/index.js +0 -1
- package/bidi/input.js +27 -3
- package/bidi/interceptPhase.js +4 -0
- package/bidi/logEntries.js +66 -0
- package/bidi/network.js +102 -0
- package/bidi/networkTypes.js +346 -1
- package/bidi/partialCookie.js +48 -0
- package/bidi/partitionDescriptor.js +33 -0
- package/bidi/partitionKey.js +17 -0
- package/bidi/protocolType.js +20 -0
- package/bidi/protocolValue.js +129 -2
- package/bidi/provideResponseParameters.js +40 -0
- package/bidi/realmInfo.js +27 -0
- package/bidi/resultOwnership.js +4 -0
- package/bidi/scriptManager.js +119 -1
- package/bidi/scriptTypes.js +36 -0
- package/bidi/storage.js +30 -0
- package/bidi/urlPattern.js +35 -0
- package/bin/linux/selenium-manager +0 -0
- package/bin/macos/selenium-manager +0 -0
- package/bin/windows/selenium-manager.exe +0 -0
- package/chromium.js +12 -9
- package/common/driverFinder.js +36 -4
- package/common/seleniumManager.js +7 -39
- package/eslint.config.js +107 -0
- package/firefox.js +20 -6
- package/http/index.js +6 -6
- package/ie.js +8 -4
- package/index.js +11 -0
- package/io/exec.js +1 -1
- package/io/index.js +3 -2
- package/io/zip.js +1 -1
- package/lib/atoms/find-elements.js +2 -2
- package/lib/http.js +5 -4
- package/lib/input.js +0 -1
- package/lib/pinnedScript.js +1 -1
- package/lib/select.js +5 -5
- package/lib/until.js +3 -3
- package/lib/util.js +1 -0
- package/lib/webdriver.js +2 -2
- package/net/index.js +1 -1
- package/net/portprober.js +1 -1
- package/package.json +12 -6
- package/remote/index.js +1 -1
- package/remote/util.js +2 -2
- package/safari.js +3 -3
- package/testing/index.js +12 -8
package/bidi/scriptManager.js
CHANGED
|
@@ -27,6 +27,11 @@ const { RemoteValue } = require('./protocolValue')
|
|
|
27
27
|
const { Source } = require('./scriptTypes')
|
|
28
28
|
const { WebDriverError } = require('../lib/error')
|
|
29
29
|
|
|
30
|
+
/**
|
|
31
|
+
* Represents class to run events and commands of Script module.
|
|
32
|
+
* Described in https://w3c.github.io/webdriver-bidi/#module-script.
|
|
33
|
+
* @class
|
|
34
|
+
*/
|
|
30
35
|
class ScriptManager {
|
|
31
36
|
constructor(driver) {
|
|
32
37
|
this._driver = driver
|
|
@@ -41,6 +46,13 @@ class ScriptManager {
|
|
|
41
46
|
this._browsingContextIds = browsingContextIds
|
|
42
47
|
}
|
|
43
48
|
|
|
49
|
+
/**
|
|
50
|
+
* Disowns the handles in the specified realm.
|
|
51
|
+
*
|
|
52
|
+
* @param {string} realmId - The ID of the realm.
|
|
53
|
+
* @param {string[]} handles - The handles to disown to allow garbage collection.
|
|
54
|
+
* @returns {Promise<void>} - A promise that resolves when the command is sent.
|
|
55
|
+
*/
|
|
44
56
|
async disownRealmScript(realmId, handles) {
|
|
45
57
|
const params = {
|
|
46
58
|
method: 'script.disown',
|
|
@@ -55,6 +67,13 @@ class ScriptManager {
|
|
|
55
67
|
await this.bidi.send(params)
|
|
56
68
|
}
|
|
57
69
|
|
|
70
|
+
/**
|
|
71
|
+
* Disowns the handles in the specified browsing context.
|
|
72
|
+
* @param {string} browsingContextId - The ID of the browsing context.
|
|
73
|
+
* @param {string[]} handles - The handles to disown to allow garbage collection.
|
|
74
|
+
* @param {String|null} [sandbox=null] - The sandbox name.
|
|
75
|
+
* @returns {Promise<void>} - A promise that resolves when the command is sent.
|
|
76
|
+
*/
|
|
58
77
|
async disownBrowsingContextScript(browsingContextId, handles, sandbox = null) {
|
|
59
78
|
const params = {
|
|
60
79
|
method: 'script.disown',
|
|
@@ -73,6 +92,17 @@ class ScriptManager {
|
|
|
73
92
|
await this.bidi.send(params)
|
|
74
93
|
}
|
|
75
94
|
|
|
95
|
+
/**
|
|
96
|
+
* Calls a function in the specified realm.
|
|
97
|
+
*
|
|
98
|
+
* @param {string} realmId - The ID of the realm.
|
|
99
|
+
* @param {string} functionDeclaration - The function to call.
|
|
100
|
+
* @param {boolean} awaitPromise - Whether to await the promise returned by the function.
|
|
101
|
+
* @param {LocalValue[]} [argumentValueList|null] - The list of argument values to pass to the function.
|
|
102
|
+
* @param {Object} [thisParameter|null] - The value of 'this' parameter for the function.
|
|
103
|
+
* @param {ResultOwnership} [resultOwnership|null] - The ownership of the result.
|
|
104
|
+
* @returns {Promise<EvaluateResultSuccess|EvaluateResultException>} - A promise that resolves to the evaluation result or exception.
|
|
105
|
+
*/
|
|
76
106
|
async callFunctionInRealm(
|
|
77
107
|
realmId,
|
|
78
108
|
functionDeclaration,
|
|
@@ -101,6 +131,17 @@ class ScriptManager {
|
|
|
101
131
|
return this.createEvaluateResult(response)
|
|
102
132
|
}
|
|
103
133
|
|
|
134
|
+
/**
|
|
135
|
+
* Calls a function in the specified browsing context.
|
|
136
|
+
*
|
|
137
|
+
* @param {string} realmId - The ID of the browsing context.
|
|
138
|
+
* @param {string} functionDeclaration - The function to call.
|
|
139
|
+
* @param {boolean} awaitPromise - Whether to await the promise returned by the function.
|
|
140
|
+
* @param {LocalValue[]} [argumentValueList|null] - The list of argument values to pass to the function.
|
|
141
|
+
* @param {Object} [thisParameter|null] - The value of 'this' parameter for the function.
|
|
142
|
+
* @param {ResultOwnership} [resultOwnership|null] - The ownership of the result.
|
|
143
|
+
* @returns {Promise<EvaluateResultSuccess|EvaluateResultException>} - A promise that resolves to the evaluation result or exception.
|
|
144
|
+
*/
|
|
104
145
|
async callFunctionInBrowsingContext(
|
|
105
146
|
browsingContextId,
|
|
106
147
|
functionDeclaration,
|
|
@@ -129,6 +170,15 @@ class ScriptManager {
|
|
|
129
170
|
return this.createEvaluateResult(response)
|
|
130
171
|
}
|
|
131
172
|
|
|
173
|
+
/**
|
|
174
|
+
* Evaluates a function in the specified realm.
|
|
175
|
+
*
|
|
176
|
+
* @param {string} realmId - The ID of the realm.
|
|
177
|
+
* @param {string} expression - The expression to function to evaluate.
|
|
178
|
+
* @param {boolean} awaitPromise - Whether to await the promise.
|
|
179
|
+
* @param {ResultOwnership|null} resultOwnership - The ownership of the result.
|
|
180
|
+
* @returns {Promise<EvaluateResultSuccess|EvaluateResultException>} - A promise that resolves to the evaluation result or exception.
|
|
181
|
+
*/
|
|
132
182
|
async evaluateFunctionInRealm(realmId, expression, awaitPromise, resultOwnership = null) {
|
|
133
183
|
const params = this.getEvaluateParams('realm', realmId, null, expression, awaitPromise, resultOwnership)
|
|
134
184
|
|
|
@@ -141,6 +191,15 @@ class ScriptManager {
|
|
|
141
191
|
return this.createEvaluateResult(response)
|
|
142
192
|
}
|
|
143
193
|
|
|
194
|
+
/**
|
|
195
|
+
* Evaluates a function in the browsing context.
|
|
196
|
+
*
|
|
197
|
+
* @param {string} realmId - The ID of the browsing context.
|
|
198
|
+
* @param {string} expression - The expression to function to evaluate.
|
|
199
|
+
* @param {boolean} awaitPromise - Whether to await the promise.
|
|
200
|
+
* @param {ResultOwnership|null} resultOwnership - The ownership of the result.
|
|
201
|
+
* @returns {Promise<EvaluateResultSuccess|EvaluateResultException>} - A promise that resolves to the evaluation result or exception.
|
|
202
|
+
*/
|
|
144
203
|
async evaluateFunctionInBrowsingContext(
|
|
145
204
|
browsingContextId,
|
|
146
205
|
expression,
|
|
@@ -166,11 +225,22 @@ class ScriptManager {
|
|
|
166
225
|
return this.createEvaluateResult(response)
|
|
167
226
|
}
|
|
168
227
|
|
|
228
|
+
/**
|
|
229
|
+
* Adds a preload script.
|
|
230
|
+
*
|
|
231
|
+
* @param {string} functionDeclaration - The declaration of the function to be added as a preload script.
|
|
232
|
+
* @param {LocalValue[]} [argumentValueList=[]] - The list of argument values to be passed to the preload script function.
|
|
233
|
+
* @param {string} [sandbox|null] - The sandbox object to be used for the preload script.
|
|
234
|
+
* @returns {Promise<number>} - A promise that resolves to the added preload script ID.
|
|
235
|
+
*/
|
|
169
236
|
async addPreloadScript(functionDeclaration, argumentValueList = [], sandbox = null) {
|
|
170
237
|
const params = {
|
|
171
238
|
functionDeclaration: functionDeclaration,
|
|
172
239
|
arguments: argumentValueList,
|
|
173
|
-
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
if (sandbox !== null) {
|
|
243
|
+
params.sandbox = sandbox
|
|
174
244
|
}
|
|
175
245
|
|
|
176
246
|
if (Array.isArray(this._browsingContextIds) && this._browsingContextIds.length > 0) {
|
|
@@ -190,6 +260,13 @@ class ScriptManager {
|
|
|
190
260
|
return response.result.script
|
|
191
261
|
}
|
|
192
262
|
|
|
263
|
+
/**
|
|
264
|
+
* Removes a preload script.
|
|
265
|
+
*
|
|
266
|
+
* @param {string} script - The ID for the script to be removed.
|
|
267
|
+
* @returns {Promise<any>} - A promise that resolves with the result of the removal.
|
|
268
|
+
* @throws {WebDriverError} - If an error occurs during the removal process.
|
|
269
|
+
*/
|
|
193
270
|
async removePreloadScript(script) {
|
|
194
271
|
const params = { script: script }
|
|
195
272
|
const command = {
|
|
@@ -290,6 +367,10 @@ class ScriptManager {
|
|
|
290
367
|
return realmsList
|
|
291
368
|
}
|
|
292
369
|
|
|
370
|
+
/**
|
|
371
|
+
* Retrieves all realms.
|
|
372
|
+
* @returns {Promise<RealmInfo[]>} - A promise that resolves to an array of RealmInfo objects.
|
|
373
|
+
*/
|
|
293
374
|
async getAllRealms() {
|
|
294
375
|
const command = {
|
|
295
376
|
method: 'script.getRealms',
|
|
@@ -299,6 +380,12 @@ class ScriptManager {
|
|
|
299
380
|
return this.realmInfoMapper(response.result.realms)
|
|
300
381
|
}
|
|
301
382
|
|
|
383
|
+
/**
|
|
384
|
+
* Retrieves the realms by type.
|
|
385
|
+
*
|
|
386
|
+
* @param {Type} type - The type of realms to retrieve.
|
|
387
|
+
* @returns {Promise<RealmInfo[]>} - A promise that resolves to an array of RealmInfo objects.
|
|
388
|
+
*/
|
|
302
389
|
async getRealmsByType(type) {
|
|
303
390
|
const command = {
|
|
304
391
|
method: 'script.getRealms',
|
|
@@ -308,6 +395,12 @@ class ScriptManager {
|
|
|
308
395
|
return this.realmInfoMapper(response.result.realms)
|
|
309
396
|
}
|
|
310
397
|
|
|
398
|
+
/**
|
|
399
|
+
* Retrieves the realms in the specified browsing context.
|
|
400
|
+
*
|
|
401
|
+
* @param {string} browsingContext - The browsing context ID.
|
|
402
|
+
* @returns {Promise<RealmInfo[]>} - A promise that resolves to an array of RealmInfo objects.
|
|
403
|
+
*/
|
|
311
404
|
async getRealmsInBrowsingContext(browsingContext) {
|
|
312
405
|
const command = {
|
|
313
406
|
method: 'script.getRealms',
|
|
@@ -317,6 +410,13 @@ class ScriptManager {
|
|
|
317
410
|
return this.realmInfoMapper(response.result.realms)
|
|
318
411
|
}
|
|
319
412
|
|
|
413
|
+
/**
|
|
414
|
+
* Retrieves the realms in a browsing context based on the specified type.
|
|
415
|
+
*
|
|
416
|
+
* @param {string} browsingContext - The browsing context ID.
|
|
417
|
+
* @param {string} type - The type of realms to retrieve.
|
|
418
|
+
* @returns {Promise<RealmInfo[]>} - A promise that resolves to an array of RealmInfo objects.
|
|
419
|
+
*/
|
|
320
420
|
async getRealmsInBrowsingContextByType(browsingContext, type) {
|
|
321
421
|
const command = {
|
|
322
422
|
method: 'script.getRealms',
|
|
@@ -326,14 +426,32 @@ class ScriptManager {
|
|
|
326
426
|
return this.realmInfoMapper(response.result.realms)
|
|
327
427
|
}
|
|
328
428
|
|
|
429
|
+
/**
|
|
430
|
+
* Subscribes to the 'script.message' event and handles the callback function when a message is received.
|
|
431
|
+
*
|
|
432
|
+
* @param {Function} callback - The callback function to be executed when a message is received.
|
|
433
|
+
* @returns {Promise<void>} - A promise that resolves when the subscription is successful.
|
|
434
|
+
*/
|
|
329
435
|
async onMessage(callback) {
|
|
330
436
|
await this.subscribeAndHandleEvent('script.message', callback)
|
|
331
437
|
}
|
|
332
438
|
|
|
439
|
+
/**
|
|
440
|
+
* Subscribes to the 'script.realmCreated' event and handles it with the provided callback.
|
|
441
|
+
*
|
|
442
|
+
* @param {Function} callback - The callback function to handle the 'script.realmCreated' event.
|
|
443
|
+
* @returns {Promise<void>} - A promise that resolves when the subscription is successful.
|
|
444
|
+
*/
|
|
333
445
|
async onRealmCreated(callback) {
|
|
334
446
|
await this.subscribeAndHandleEvent('script.realmCreated', callback)
|
|
335
447
|
}
|
|
336
448
|
|
|
449
|
+
/**
|
|
450
|
+
* Subscribes to the 'script.realmDestroyed' event and handles it with the provided callback function.
|
|
451
|
+
*
|
|
452
|
+
* @param {Function} callback - The callback function to be executed when the 'script.realmDestroyed' event occurs.
|
|
453
|
+
* @returns {Promise<void>} - A promise that resolves when the subscription is successful.
|
|
454
|
+
*/
|
|
337
455
|
async onRealmDestroyed(callback) {
|
|
338
456
|
await this.subscribeAndHandleEvent('script.realmDestroyed', callback)
|
|
339
457
|
}
|
package/bidi/scriptTypes.js
CHANGED
|
@@ -15,26 +15,54 @@
|
|
|
15
15
|
// specific language governing permissions and limitations
|
|
16
16
|
// under the License.
|
|
17
17
|
|
|
18
|
+
/**
|
|
19
|
+
* Represents a message received through a channel.
|
|
20
|
+
* Described in https://w3c.github.io/webdriver-bidi/#event-script-message.
|
|
21
|
+
* @class
|
|
22
|
+
*/
|
|
18
23
|
class Message {
|
|
24
|
+
/**
|
|
25
|
+
* Creates a new Message instance.
|
|
26
|
+
* @param {string} channel - The channel through which the message is received.
|
|
27
|
+
* @param {RemoteValue} data - The data contained in the message.
|
|
28
|
+
* @param {Source} source - The source of the message.
|
|
29
|
+
*/
|
|
19
30
|
constructor(channel, data, source) {
|
|
20
31
|
this._channel = channel
|
|
21
32
|
this._data = data
|
|
22
33
|
this._source = source
|
|
23
34
|
}
|
|
24
35
|
|
|
36
|
+
/**
|
|
37
|
+
* Gets the channel through which the message is received.
|
|
38
|
+
* @returns {string} The channel.
|
|
39
|
+
*/
|
|
25
40
|
get channel() {
|
|
26
41
|
return this._channel
|
|
27
42
|
}
|
|
28
43
|
|
|
44
|
+
/**
|
|
45
|
+
* Gets the data contained in the message.
|
|
46
|
+
* @returns {RemoteValue} The data.
|
|
47
|
+
*/
|
|
29
48
|
get data() {
|
|
30
49
|
return this._data
|
|
31
50
|
}
|
|
32
51
|
|
|
52
|
+
/**
|
|
53
|
+
* Gets the source of the message.
|
|
54
|
+
* @returns {Source} The source.
|
|
55
|
+
*/
|
|
33
56
|
get source() {
|
|
34
57
|
return this._source
|
|
35
58
|
}
|
|
36
59
|
}
|
|
37
60
|
|
|
61
|
+
/**
|
|
62
|
+
* Represents a source object.
|
|
63
|
+
* Described in https://w3c.github.io/webdriver-bidi/#type-script-Source.
|
|
64
|
+
* @class
|
|
65
|
+
*/
|
|
38
66
|
class Source {
|
|
39
67
|
constructor(source) {
|
|
40
68
|
this._browsingContextId = null
|
|
@@ -46,10 +74,18 @@ class Source {
|
|
|
46
74
|
}
|
|
47
75
|
}
|
|
48
76
|
|
|
77
|
+
/**
|
|
78
|
+
* Get the browsing context ID.
|
|
79
|
+
* @returns {string|null} The browsing context ID.
|
|
80
|
+
*/
|
|
49
81
|
get browsingContextId() {
|
|
50
82
|
return this._browsingContextId
|
|
51
83
|
}
|
|
52
84
|
|
|
85
|
+
/**
|
|
86
|
+
* Get the realm ID.
|
|
87
|
+
* @returns {string} The realm ID.
|
|
88
|
+
*/
|
|
53
89
|
get realmId() {
|
|
54
90
|
return this._realmId
|
|
55
91
|
}
|
package/bidi/storage.js
CHANGED
|
@@ -21,6 +21,11 @@ const { PartitionKey } = require('./partitionKey')
|
|
|
21
21
|
const { PartialCookie } = require('./partialCookie')
|
|
22
22
|
const { Cookie, BytesValue } = require('./networkTypes')
|
|
23
23
|
|
|
24
|
+
/**
|
|
25
|
+
* Represents commands of Storage module.
|
|
26
|
+
* Described in https://w3c.github.io/webdriver-bidi/#module-storage.
|
|
27
|
+
* @class
|
|
28
|
+
*/
|
|
24
29
|
class Storage {
|
|
25
30
|
constructor(driver) {
|
|
26
31
|
this._driver = driver
|
|
@@ -34,6 +39,15 @@ class Storage {
|
|
|
34
39
|
this.bidi = await this._driver.getBidi()
|
|
35
40
|
}
|
|
36
41
|
|
|
42
|
+
/**
|
|
43
|
+
* Retrieves cookies based on the provided filter and partition.
|
|
44
|
+
*
|
|
45
|
+
* @param {CookieFilter} [filter] - The filter to apply to the cookies.
|
|
46
|
+
* @param {(BrowsingContextPartitionDescriptor|StorageKeyPartitionDescriptor)} [partition] - The partition to retrieve cookies from.
|
|
47
|
+
* @returns {Promise<{ cookies: Cookie[], partitionKey?: PartitionKey }>} - A promise that resolves to an object containing the retrieved cookies and an optional partition key.
|
|
48
|
+
* @throws {Error} If the filter parameter is provided but is not an instance of CookieFilter.
|
|
49
|
+
* @throws {Error} If the partition parameter is provided but is not an instance of BrowsingContextPartitionDescriptor or StorageKeyPartitionDescriptor.
|
|
50
|
+
*/
|
|
37
51
|
async getCookies(filter = undefined, partition = undefined) {
|
|
38
52
|
if (filter !== undefined && !(filter instanceof CookieFilter)) {
|
|
39
53
|
throw new Error(`Params must be an instance of CookieFilter. Received:'${filter}'`)
|
|
@@ -89,6 +103,14 @@ class Storage {
|
|
|
89
103
|
}
|
|
90
104
|
}
|
|
91
105
|
|
|
106
|
+
/**
|
|
107
|
+
* Sets a cookie using the provided cookie object and partition.
|
|
108
|
+
*
|
|
109
|
+
* @param {PartialCookie} cookie - The cookie object to set.
|
|
110
|
+
* @param {(BrowsingContextPartitionDescriptor|StorageKeyPartitionDescriptor)} [partition] - The partition to use for the cookie.
|
|
111
|
+
* @returns {PartitionKey} The partition key of the set cookie.
|
|
112
|
+
* @throws {Error} If the cookie parameter is not an instance of PartialCookie or if the partition parameter is not an instance of PartitionDescriptor.
|
|
113
|
+
*/
|
|
92
114
|
async setCookie(cookie, partition = undefined) {
|
|
93
115
|
if (!(cookie instanceof PartialCookie)) {
|
|
94
116
|
throw new Error(`Params must be an instance of PartialCookie. Received:'${cookie}'`)
|
|
@@ -125,6 +147,14 @@ class Storage {
|
|
|
125
147
|
}
|
|
126
148
|
}
|
|
127
149
|
|
|
150
|
+
/**
|
|
151
|
+
* Deletes cookies based on the provided filter and partition.
|
|
152
|
+
*
|
|
153
|
+
* @param {CookieFilter} [cookieFilter] - The filter to apply to the cookies. Must be an instance of CookieFilter.
|
|
154
|
+
* @param {(BrowsingContextPartitionDescriptor|StorageKeyPartitionDescriptor)} [partition] - The partition to delete cookies from. Must be an instance of either BrowsingContextPartitionDescriptor or StorageKeyPartitionDescriptor.
|
|
155
|
+
* @returns {PartitionKey} - The partition key of the deleted cookies, if available.
|
|
156
|
+
* @throws {Error} - If the provided parameters are not of the correct type.
|
|
157
|
+
*/
|
|
128
158
|
async deleteCookies(cookieFilter = undefined, partition = undefined) {
|
|
129
159
|
if (cookieFilter !== undefined && !(cookieFilter instanceof CookieFilter)) {
|
|
130
160
|
throw new Error(`Params must be an instance of CookieFilter. Received:'${cookieFilter}'`)
|
package/bidi/urlPattern.js
CHANGED
|
@@ -15,19 +15,42 @@
|
|
|
15
15
|
// specific language governing permissions and limitations
|
|
16
16
|
// under the License.
|
|
17
17
|
|
|
18
|
+
/**
|
|
19
|
+
* Represents a URL pattern to intercept.
|
|
20
|
+
* Described in network.UrlPatternPattern https://w3c.github.io/webdriver-bidi/#type-network-UrlPattern
|
|
21
|
+
*/
|
|
18
22
|
class UrlPattern {
|
|
19
23
|
#map = new Map()
|
|
20
24
|
|
|
25
|
+
/**
|
|
26
|
+
* Sets the protocol for the URL pattern.
|
|
27
|
+
*
|
|
28
|
+
* @param {string} protocol - The protocol to set.
|
|
29
|
+
* @returns {UrlPattern} - Returns the updated instance of the URL pattern for chaining.
|
|
30
|
+
*/
|
|
21
31
|
protocol(protocol) {
|
|
22
32
|
this.#map.set('protocol', protocol)
|
|
23
33
|
return this
|
|
24
34
|
}
|
|
25
35
|
|
|
36
|
+
/**
|
|
37
|
+
* Sets the hostname for the URL pattern.
|
|
38
|
+
*
|
|
39
|
+
* @param {string} hostname - The hostname to set.
|
|
40
|
+
* @returns {UrlPattern} - Returns the updated instance of the URL pattern for chaining.
|
|
41
|
+
*/
|
|
26
42
|
hostname(hostname) {
|
|
27
43
|
this.#map.set('hostname', hostname)
|
|
28
44
|
return this
|
|
29
45
|
}
|
|
30
46
|
|
|
47
|
+
/**
|
|
48
|
+
* Sets the port for the URL pattern.
|
|
49
|
+
*
|
|
50
|
+
* @param {number} port - The port number to set.
|
|
51
|
+
* @returns {UrlPattern} - Returns the updated instance of the URL pattern for chaining.
|
|
52
|
+
* @throws {Error} - Throws an error if the port is not a number.
|
|
53
|
+
*/
|
|
31
54
|
port(port) {
|
|
32
55
|
if (typeof port === 'number') {
|
|
33
56
|
this.#map.set('port', port.toString())
|
|
@@ -37,11 +60,23 @@ class UrlPattern {
|
|
|
37
60
|
return this
|
|
38
61
|
}
|
|
39
62
|
|
|
63
|
+
/**
|
|
64
|
+
* Sets the pathname for the URL pattern.
|
|
65
|
+
*
|
|
66
|
+
* @param {string} pathname - The pathname to set.
|
|
67
|
+
* @returns {UrlPattern} - Returns the updated instance of the URL pattern for chaining.
|
|
68
|
+
*/
|
|
40
69
|
pathname(pathname) {
|
|
41
70
|
this.#map.set('pathname', pathname)
|
|
42
71
|
return this
|
|
43
72
|
}
|
|
44
73
|
|
|
74
|
+
/**
|
|
75
|
+
* Sets the search parameter in the URL pattern.
|
|
76
|
+
*
|
|
77
|
+
* @param {string} search - The search parameter to be set.
|
|
78
|
+
* @returns {UrlPattern} - Returns the updated instance of the URL pattern for chaining.
|
|
79
|
+
*/
|
|
45
80
|
search(search) {
|
|
46
81
|
this.#map.set('search', search)
|
|
47
82
|
return this
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/chromium.js
CHANGED
|
@@ -78,7 +78,7 @@ const error = require('./lib/error')
|
|
|
78
78
|
const Symbols = require('./lib/symbols')
|
|
79
79
|
const webdriver = require('./lib/webdriver')
|
|
80
80
|
const remote = require('./remote')
|
|
81
|
-
const {
|
|
81
|
+
const { getBinaryPaths } = require('./common/driverFinder')
|
|
82
82
|
|
|
83
83
|
/**
|
|
84
84
|
* Custom command names supported by Chromium WebDriver.
|
|
@@ -622,14 +622,17 @@ class Driver extends webdriver.WebDriver {
|
|
|
622
622
|
} else {
|
|
623
623
|
let service = opt_serviceExecutor || this.getDefaultService()
|
|
624
624
|
if (!service.getExecutable()) {
|
|
625
|
-
const { driverPath, browserPath } =
|
|
625
|
+
const { driverPath, browserPath } = getBinaryPaths(caps)
|
|
626
626
|
service.setExecutable(driverPath)
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
vendorOptions
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
627
|
+
if (browserPath) {
|
|
628
|
+
const vendorOptions = caps.get(vendorCapabilityKey)
|
|
629
|
+
if (vendorOptions) {
|
|
630
|
+
vendorOptions['binary'] = browserPath
|
|
631
|
+
caps.set(vendorCapabilityKey, vendorOptions)
|
|
632
|
+
} else {
|
|
633
|
+
caps.set(vendorCapabilityKey, { binary: browserPath })
|
|
634
|
+
}
|
|
635
|
+
caps.delete(Capability.BROWSER_VERSION)
|
|
633
636
|
}
|
|
634
637
|
}
|
|
635
638
|
onQuit = () => service.kill()
|
|
@@ -743,7 +746,7 @@ class Driver extends webdriver.WebDriver {
|
|
|
743
746
|
* Set a permission state to the given value.
|
|
744
747
|
*
|
|
745
748
|
* @param {string} name A name of the permission to update.
|
|
746
|
-
* @param {(
|
|
749
|
+
* @param {("granted"|"denied"|"prompt")} state State to set permission to.
|
|
747
750
|
* @returns {!Promise<Object>} A promise that will be resolved when the
|
|
748
751
|
* command has finished.
|
|
749
752
|
* @see <https://w3c.github.io/permissions/#permission-registry> for valid
|
package/common/driverFinder.js
CHANGED
|
@@ -21,16 +21,19 @@
|
|
|
21
21
|
* Utility to find if a given file is present and executable.
|
|
22
22
|
*/
|
|
23
23
|
|
|
24
|
-
const
|
|
24
|
+
const path = require('node:path')
|
|
25
|
+
const { binaryPaths } = require('./seleniumManager')
|
|
25
26
|
|
|
26
27
|
/**
|
|
27
28
|
* Determines the path of the correct Selenium Manager binary
|
|
29
|
+
* @param {Capabilities} capabilities browser options to fetch the driver
|
|
28
30
|
* @returns {{browserPath: string, driverPath: string}} path of the driver
|
|
29
31
|
* and browser location
|
|
30
32
|
*/
|
|
31
|
-
function
|
|
33
|
+
function getBinaryPaths(capabilities) {
|
|
32
34
|
try {
|
|
33
|
-
|
|
35
|
+
const args = getArgs(capabilities)
|
|
36
|
+
return binaryPaths(args)
|
|
34
37
|
} catch (e) {
|
|
35
38
|
throw Error(
|
|
36
39
|
`Unable to obtain browser driver.
|
|
@@ -40,5 +43,34 @@ function getPath(capabilities) {
|
|
|
40
43
|
}
|
|
41
44
|
}
|
|
42
45
|
|
|
46
|
+
function getArgs(options) {
|
|
47
|
+
let args = ['--browser', options.getBrowserName(), '--language-binding', 'javascript', '--output', 'json']
|
|
48
|
+
|
|
49
|
+
if (options.getBrowserVersion() && options.getBrowserVersion() !== '') {
|
|
50
|
+
args.push('--browser-version', options.getBrowserVersion())
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const vendorOptions =
|
|
54
|
+
options.get('goog:chromeOptions') || options.get('ms:edgeOptions') || options.get('moz:firefoxOptions')
|
|
55
|
+
if (vendorOptions && vendorOptions.binary && vendorOptions.binary !== '') {
|
|
56
|
+
args.push('--browser-path', path.resolve(vendorOptions.binary))
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const proxyOptions = options.getProxy()
|
|
60
|
+
|
|
61
|
+
// Check if proxyOptions exists and has properties
|
|
62
|
+
if (proxyOptions && Object.keys(proxyOptions).length > 0) {
|
|
63
|
+
const httpProxy = proxyOptions['httpProxy']
|
|
64
|
+
const sslProxy = proxyOptions['sslProxy']
|
|
65
|
+
|
|
66
|
+
if (httpProxy !== undefined) {
|
|
67
|
+
args.push('--proxy', httpProxy)
|
|
68
|
+
} else if (sslProxy !== undefined) {
|
|
69
|
+
args.push('--proxy', sslProxy)
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return args
|
|
73
|
+
}
|
|
74
|
+
|
|
43
75
|
// PUBLIC API
|
|
44
|
-
module.exports = {
|
|
76
|
+
module.exports = { getBinaryPaths }
|
|
@@ -21,11 +21,10 @@
|
|
|
21
21
|
* Wrapper for getting information from the Selenium Manager binaries
|
|
22
22
|
*/
|
|
23
23
|
|
|
24
|
-
const { platform } = require('process')
|
|
25
|
-
const path = require('path')
|
|
26
|
-
const fs = require('fs')
|
|
27
|
-
const spawnSync = require('child_process').spawnSync
|
|
28
|
-
const { Capability } = require('../lib/capabilities')
|
|
24
|
+
const { platform } = require('node:process')
|
|
25
|
+
const path = require('node:path')
|
|
26
|
+
const fs = require('node:fs')
|
|
27
|
+
const spawnSync = require('node:child_process').spawnSync
|
|
29
28
|
const logging = require('../lib/logging')
|
|
30
29
|
|
|
31
30
|
const log_ = logging.getLogger(logging.Type.DRIVER)
|
|
@@ -63,38 +62,12 @@ function getBinary() {
|
|
|
63
62
|
|
|
64
63
|
/**
|
|
65
64
|
* Determines the path of the correct driver
|
|
66
|
-
* @param {
|
|
65
|
+
* @param {string[]} args arguments to invoke Selenium Manager
|
|
67
66
|
* @returns {{browserPath: string, driverPath: string}} path of the driver and
|
|
68
67
|
* browser location
|
|
69
68
|
*/
|
|
70
69
|
|
|
71
|
-
function
|
|
72
|
-
let args = ['--browser', options.getBrowserName(), '--language-binding', 'javascript', '--output', 'json']
|
|
73
|
-
|
|
74
|
-
if (options.getBrowserVersion() && options.getBrowserVersion() !== '') {
|
|
75
|
-
args.push('--browser-version', options.getBrowserVersion())
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
const vendorOptions =
|
|
79
|
-
options.get('goog:chromeOptions') || options.get('ms:edgeOptions') || options.get('moz:firefoxOptions')
|
|
80
|
-
if (vendorOptions && vendorOptions.binary && vendorOptions.binary !== '') {
|
|
81
|
-
args.push('--browser-path', path.resolve(vendorOptions.binary))
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
const proxyOptions = options.getProxy()
|
|
85
|
-
|
|
86
|
-
// Check if proxyOptions exists and has properties
|
|
87
|
-
if (proxyOptions && Object.keys(proxyOptions).length > 0) {
|
|
88
|
-
const httpProxy = proxyOptions['httpProxy']
|
|
89
|
-
const sslProxy = proxyOptions['sslProxy']
|
|
90
|
-
|
|
91
|
-
if (httpProxy !== undefined) {
|
|
92
|
-
args.push('--proxy', httpProxy)
|
|
93
|
-
} else if (sslProxy !== undefined) {
|
|
94
|
-
args.push('--proxy', sslProxy)
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
|
|
70
|
+
function binaryPaths(args) {
|
|
98
71
|
const smBinary = getBinary()
|
|
99
72
|
const spawnResult = spawnSync(smBinary, args)
|
|
100
73
|
let output
|
|
@@ -120,11 +93,6 @@ function driverLocation(options) {
|
|
|
120
93
|
throw new Error(`Error executing command for ${smBinary} with ${args}: ${e.toString()}`)
|
|
121
94
|
}
|
|
122
95
|
|
|
123
|
-
// Once driverPath is available, delete browserVersion from payload
|
|
124
|
-
if (output.result.driver_path) {
|
|
125
|
-
options.delete(Capability.BROWSER_VERSION)
|
|
126
|
-
}
|
|
127
|
-
|
|
128
96
|
logOutput(output)
|
|
129
97
|
return {
|
|
130
98
|
driverPath: output.result.driver_path,
|
|
@@ -144,4 +112,4 @@ function logOutput(output) {
|
|
|
144
112
|
}
|
|
145
113
|
|
|
146
114
|
// PUBLIC API
|
|
147
|
-
module.exports = {
|
|
115
|
+
module.exports = { binaryPaths }
|