selenium-webdriver 4.18.1 → 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 +946 -743
- package/README.md +71 -72
- package/bidi/addInterceptParameters.js +65 -45
- package/bidi/argumentValue.js +1 -0
- package/bidi/browser.js +94 -0
- package/bidi/browsingContext.js +214 -32
- 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 +122 -0
- package/bidi/continueResponseParameters.js +129 -0
- package/bidi/cookieFilter.js +139 -0
- package/bidi/createContextParameters.js +73 -0
- package/bidi/evaluateResult.js +17 -0
- package/bidi/index.js +25 -26
- package/bidi/input.js +47 -3
- package/bidi/interceptPhase.js +5 -1
- package/bidi/logEntries.js +66 -0
- package/bidi/network.js +176 -23
- package/bidi/networkTypes.js +394 -17
- package/bidi/partialCookie.js +115 -0
- package/bidi/partitionDescriptor.js +102 -0
- package/bidi/partitionKey.js +53 -0
- package/bidi/protocolType.js +20 -0
- package/bidi/protocolValue.js +140 -9
- package/bidi/provideResponseParameters.js +123 -0
- package/bidi/realmInfo.js +27 -0
- package/bidi/resultOwnership.js +4 -0
- package/bidi/scriptManager.js +131 -5
- package/bidi/scriptTypes.js +36 -0
- package/bidi/storage.js +201 -0
- package/bidi/urlPattern.js +36 -3
- 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 +13 -9
- package/common/driverFinder.js +36 -4
- package/common/seleniumManager.js +7 -39
- package/devtools/CDPConnection.js +1 -0
- package/devtools/networkinterceptor.js +1 -0
- package/eslint.config.js +107 -0
- package/firefox.js +20 -6
- package/http/index.js +6 -6
- package/http/util.js +1 -0
- 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 +26 -26
- package/lib/atoms/is-displayed.js +24 -97
- package/lib/capabilities.js +5 -5
- package/lib/http.js +8 -4
- package/lib/input.js +0 -1
- package/lib/pinnedScript.js +1 -1
- package/lib/select.js +8 -8
- package/lib/until.js +3 -3
- package/lib/util.js +1 -0
- package/lib/virtual_authenticator.js +8 -8
- package/lib/webdriver.js +8 -3
- package/net/index.js +1 -1
- package/net/portprober.js +1 -1
- package/package.json +21 -13
- package/remote/index.js +1 -1
- package/remote/util.js +2 -2
- package/safari.js +3 -3
- package/testing/index.js +17 -8
package/bidi/index.js
CHANGED
|
@@ -15,7 +15,6 @@
|
|
|
15
15
|
// specific language governing permissions and limitations
|
|
16
16
|
// under the License.
|
|
17
17
|
|
|
18
|
-
// eslint-disable-next-line node/no-missing-require
|
|
19
18
|
const { EventEmitter } = require('node:events')
|
|
20
19
|
const WebSocket = require('ws')
|
|
21
20
|
|
|
@@ -40,6 +39,31 @@ class Index extends EventEmitter {
|
|
|
40
39
|
})
|
|
41
40
|
}
|
|
42
41
|
|
|
42
|
+
/**
|
|
43
|
+
* @returns {WebSocket}
|
|
44
|
+
*/
|
|
45
|
+
get socket() {
|
|
46
|
+
return this._ws
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* @returns {boolean|*}
|
|
51
|
+
*/
|
|
52
|
+
get isConnected() {
|
|
53
|
+
return this.connected
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Get Bidi Status
|
|
58
|
+
* @returns {Promise<*>}
|
|
59
|
+
*/
|
|
60
|
+
get status() {
|
|
61
|
+
return this.send({
|
|
62
|
+
method: 'session.status',
|
|
63
|
+
params: {},
|
|
64
|
+
})
|
|
65
|
+
}
|
|
66
|
+
|
|
43
67
|
/**
|
|
44
68
|
* Resolve connection
|
|
45
69
|
* @returns {Promise<unknown>}
|
|
@@ -56,20 +80,6 @@ class Index extends EventEmitter {
|
|
|
56
80
|
})
|
|
57
81
|
}
|
|
58
82
|
|
|
59
|
-
/**
|
|
60
|
-
* @returns {WebSocket}
|
|
61
|
-
*/
|
|
62
|
-
get socket() {
|
|
63
|
-
return this._ws
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* @returns {boolean|*}
|
|
68
|
-
*/
|
|
69
|
-
get isConnected() {
|
|
70
|
-
return this.connected
|
|
71
|
-
}
|
|
72
|
-
|
|
73
83
|
/**
|
|
74
84
|
* Sends a bidi request
|
|
75
85
|
* @param params
|
|
@@ -183,17 +193,6 @@ class Index extends EventEmitter {
|
|
|
183
193
|
await this.send(params)
|
|
184
194
|
}
|
|
185
195
|
|
|
186
|
-
/**
|
|
187
|
-
* Get Bidi Status
|
|
188
|
-
* @returns {Promise<*>}
|
|
189
|
-
*/
|
|
190
|
-
get status() {
|
|
191
|
-
return this.send({
|
|
192
|
-
method: 'session.status',
|
|
193
|
-
params: {},
|
|
194
|
-
})
|
|
195
|
-
}
|
|
196
|
-
|
|
197
196
|
/**
|
|
198
197
|
* Close ws connection.
|
|
199
198
|
* @returns {Promise<unknown>}
|
package/bidi/input.js
CHANGED
|
@@ -18,7 +18,12 @@
|
|
|
18
18
|
// type: module added to package.json
|
|
19
19
|
// import { WebElement } from '../lib/webdriver'
|
|
20
20
|
const { WebElement } = require('../lib/webdriver')
|
|
21
|
+
const { RemoteReferenceType, ReferenceValue } = require('./protocolValue')
|
|
21
22
|
|
|
23
|
+
/**
|
|
24
|
+
* Represents commands and events related to the Input module (simulated user input).
|
|
25
|
+
* Described in https://w3c.github.io/webdriver-bidi/#module-input.
|
|
26
|
+
*/
|
|
22
27
|
class Input {
|
|
23
28
|
constructor(driver) {
|
|
24
29
|
this._driver = driver
|
|
@@ -32,6 +37,13 @@ class Input {
|
|
|
32
37
|
this.bidi = await this._driver.getBidi()
|
|
33
38
|
}
|
|
34
39
|
|
|
40
|
+
/**
|
|
41
|
+
* Performs the specified actions on the given browsing context.
|
|
42
|
+
*
|
|
43
|
+
* @param {string} browsingContextId - The ID of the browsing context.
|
|
44
|
+
* @param {Array} actions - The actions to be performed.
|
|
45
|
+
* @returns {Promise} A promise that resolves with the response from the server.
|
|
46
|
+
*/
|
|
35
47
|
async perform(browsingContextId, actions) {
|
|
36
48
|
const _actions = await updateActions(actions)
|
|
37
49
|
|
|
@@ -43,11 +55,15 @@ class Input {
|
|
|
43
55
|
},
|
|
44
56
|
}
|
|
45
57
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
return response
|
|
58
|
+
return await this.bidi.send(command)
|
|
49
59
|
}
|
|
50
60
|
|
|
61
|
+
/**
|
|
62
|
+
* Resets the input state in the specified browsing context.
|
|
63
|
+
*
|
|
64
|
+
* @param {string} browsingContextId - The ID of the browsing context.
|
|
65
|
+
* @returns {Promise} A promise that resolves when the release actions are sent.
|
|
66
|
+
*/
|
|
51
67
|
async release(browsingContextId) {
|
|
52
68
|
const command = {
|
|
53
69
|
method: 'input.releaseActions',
|
|
@@ -57,6 +73,34 @@ class Input {
|
|
|
57
73
|
}
|
|
58
74
|
return await this.bidi.send(command)
|
|
59
75
|
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Sets the files property of a given input element.
|
|
79
|
+
*
|
|
80
|
+
* @param {string} browsingContextId - The ID of the browsing context.
|
|
81
|
+
* @param {string | ReferenceValue} element - The ID of the element or a ReferenceValue object representing the element.
|
|
82
|
+
* @param {string | string[]} files - The file path or an array of file paths to be set.
|
|
83
|
+
* @throws {Error} If the element is not a string or a ReferenceValue.
|
|
84
|
+
* @returns {Promise<void>} A promise that resolves when the files are set.
|
|
85
|
+
*/
|
|
86
|
+
async setFiles(browsingContextId, element, files) {
|
|
87
|
+
if (typeof element !== 'string' && !(element instanceof ReferenceValue)) {
|
|
88
|
+
throw Error(`Pass in a WebElement id as a string or a ReferenceValue. Received: ${element}`)
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
const command = {
|
|
92
|
+
method: 'input.setFiles',
|
|
93
|
+
params: {
|
|
94
|
+
context: browsingContextId,
|
|
95
|
+
element:
|
|
96
|
+
typeof element === 'string'
|
|
97
|
+
? new ReferenceValue(RemoteReferenceType.SHARED_ID, element).asMap()
|
|
98
|
+
: element.asMap(),
|
|
99
|
+
files: typeof files === 'string' ? [files] : files,
|
|
100
|
+
},
|
|
101
|
+
}
|
|
102
|
+
await this.bidi.send(command)
|
|
103
|
+
}
|
|
60
104
|
}
|
|
61
105
|
|
|
62
106
|
async function updateActions(actions) {
|
package/bidi/interceptPhase.js
CHANGED
|
@@ -15,10 +15,14 @@
|
|
|
15
15
|
// specific language governing permissions and limitations
|
|
16
16
|
// under the License.
|
|
17
17
|
|
|
18
|
+
/**
|
|
19
|
+
* Represents the different phases of intercepting network requests and responses.
|
|
20
|
+
* @enum {string}
|
|
21
|
+
*/
|
|
18
22
|
const InterceptPhase = {
|
|
19
23
|
BEFORE_REQUEST_SENT: 'beforeRequestSent',
|
|
20
24
|
RESPONSE_STARTED: 'responseStarted',
|
|
21
25
|
AUTH_REQUIRED: 'authRequired',
|
|
22
26
|
}
|
|
23
27
|
|
|
24
|
-
module.exports = {InterceptPhase}
|
|
28
|
+
module.exports = { InterceptPhase }
|
package/bidi/logEntries.js
CHANGED
|
@@ -17,7 +17,18 @@
|
|
|
17
17
|
|
|
18
18
|
'use strict'
|
|
19
19
|
|
|
20
|
+
/**
|
|
21
|
+
* Represents a base log entry.
|
|
22
|
+
* Desribed in https://w3c.github.io/webdriver-bidi/#types-log-logentry.
|
|
23
|
+
*/
|
|
20
24
|
class BaseLogEntry {
|
|
25
|
+
/**
|
|
26
|
+
* Creates a new instance of BaseLogEntry.
|
|
27
|
+
* @param {string} level - The log level.
|
|
28
|
+
* @param {string} text - The log text.
|
|
29
|
+
* @param {number} timeStamp - The log timestamp.
|
|
30
|
+
* @param {string} stackTrace - The log stack trace.
|
|
31
|
+
*/
|
|
21
32
|
constructor(level, text, timeStamp, stackTrace) {
|
|
22
33
|
this._level = level
|
|
23
34
|
this._text = text
|
|
@@ -25,34 +36,72 @@ class BaseLogEntry {
|
|
|
25
36
|
this._stackTrace = stackTrace
|
|
26
37
|
}
|
|
27
38
|
|
|
39
|
+
/**
|
|
40
|
+
* Gets the log level.
|
|
41
|
+
* @returns {string} The log level.
|
|
42
|
+
*/
|
|
28
43
|
get level() {
|
|
29
44
|
return this._level
|
|
30
45
|
}
|
|
31
46
|
|
|
47
|
+
/**
|
|
48
|
+
* Gets the log text.
|
|
49
|
+
* @returns {string} The log text.
|
|
50
|
+
*/
|
|
32
51
|
get text() {
|
|
33
52
|
return this._text
|
|
34
53
|
}
|
|
35
54
|
|
|
55
|
+
/**
|
|
56
|
+
* Gets the log timestamp.
|
|
57
|
+
* @returns {number} The log timestamp.
|
|
58
|
+
*/
|
|
36
59
|
get timeStamp() {
|
|
37
60
|
return this._timeStamp
|
|
38
61
|
}
|
|
39
62
|
|
|
63
|
+
/**
|
|
64
|
+
* Gets the log stack trace.
|
|
65
|
+
* @returns {string} The log stack trace.
|
|
66
|
+
*/
|
|
40
67
|
get stackTrace() {
|
|
41
68
|
return this._stackTrace
|
|
42
69
|
}
|
|
43
70
|
}
|
|
44
71
|
|
|
72
|
+
/**
|
|
73
|
+
* Represents a generic log entry.
|
|
74
|
+
* @class
|
|
75
|
+
* @extends BaseLogEntry
|
|
76
|
+
*/
|
|
45
77
|
class GenericLogEntry extends BaseLogEntry {
|
|
78
|
+
/**
|
|
79
|
+
* Creates an instance of GenericLogEntry.
|
|
80
|
+
* @param {string} level - The log level.
|
|
81
|
+
* @param {string} text - The log text.
|
|
82
|
+
* @param {Date} timeStamp - The log timestamp.
|
|
83
|
+
* @param {string} type - The log type.
|
|
84
|
+
* @param {string} stackTrace - The log stack trace.
|
|
85
|
+
*/
|
|
46
86
|
constructor(level, text, timeStamp, type, stackTrace) {
|
|
47
87
|
super(level, text, timeStamp, stackTrace)
|
|
48
88
|
this._type = type
|
|
49
89
|
}
|
|
50
90
|
|
|
91
|
+
/**
|
|
92
|
+
* Gets the log type.
|
|
93
|
+
* @returns {string} The log type.
|
|
94
|
+
*/
|
|
51
95
|
get type() {
|
|
52
96
|
return this._type
|
|
53
97
|
}
|
|
54
98
|
}
|
|
55
99
|
|
|
100
|
+
/**
|
|
101
|
+
* Represents a log entry for console logs.
|
|
102
|
+
* @class
|
|
103
|
+
* @extends GenericLogEntry
|
|
104
|
+
*/
|
|
56
105
|
class ConsoleLogEntry extends GenericLogEntry {
|
|
57
106
|
constructor(level, text, timeStamp, type, method, realm, args, stackTrace) {
|
|
58
107
|
super(level, text, timeStamp, type, stackTrace)
|
|
@@ -61,19 +110,36 @@ class ConsoleLogEntry extends GenericLogEntry {
|
|
|
61
110
|
this._args = args
|
|
62
111
|
}
|
|
63
112
|
|
|
113
|
+
/**
|
|
114
|
+
* Gets the method associated with the log entry.
|
|
115
|
+
* @returns {string} The method associated with the log entry.
|
|
116
|
+
*/
|
|
64
117
|
get method() {
|
|
65
118
|
return this._method
|
|
66
119
|
}
|
|
67
120
|
|
|
121
|
+
/**
|
|
122
|
+
* Gets the realm associated with the log entry.
|
|
123
|
+
* @returns {string} The realm associated with the log entry.
|
|
124
|
+
*/
|
|
68
125
|
get realm() {
|
|
69
126
|
return this._realm
|
|
70
127
|
}
|
|
71
128
|
|
|
129
|
+
/**
|
|
130
|
+
* Gets the arguments associated with the log entry.
|
|
131
|
+
* @returns {Array} The arguments associated with the log entry.
|
|
132
|
+
*/
|
|
72
133
|
get args() {
|
|
73
134
|
return this._args
|
|
74
135
|
}
|
|
75
136
|
}
|
|
76
137
|
|
|
138
|
+
/**
|
|
139
|
+
* Represents a log entry for JavaScript logs.
|
|
140
|
+
* @class
|
|
141
|
+
* @extends GenericLogEntry
|
|
142
|
+
*/
|
|
77
143
|
class JavascriptLogEntry extends GenericLogEntry {
|
|
78
144
|
constructor(level, text, timeStamp, type, stackTrace) {
|
|
79
145
|
super(level, text, timeStamp, type, stackTrace)
|
package/bidi/network.js
CHANGED
|
@@ -15,10 +15,23 @@
|
|
|
15
15
|
// specific language governing permissions and limitations
|
|
16
16
|
// under the License.
|
|
17
17
|
|
|
18
|
-
const { BeforeRequestSent, ResponseStarted, FetchError} = require('./networkTypes')
|
|
19
|
-
const {AddInterceptParameters} = require(
|
|
18
|
+
const { BeforeRequestSent, ResponseStarted, FetchError } = require('./networkTypes')
|
|
19
|
+
const { AddInterceptParameters } = require('./addInterceptParameters')
|
|
20
|
+
const { ContinueResponseParameters } = require('./continueResponseParameters')
|
|
21
|
+
const { ContinueRequestParameters } = require('./continueRequestParameters')
|
|
22
|
+
const { ProvideResponseParameters } = require('./provideResponseParameters')
|
|
20
23
|
|
|
24
|
+
/**
|
|
25
|
+
* Represents all commands and events of Network module.
|
|
26
|
+
* Described in https://w3c.github.io/webdriver-bidi/#module-network.
|
|
27
|
+
*/
|
|
21
28
|
class Network {
|
|
29
|
+
/**
|
|
30
|
+
* Represents a Network object.
|
|
31
|
+
* @constructor
|
|
32
|
+
* @param {Driver} driver - The driver to fetch the BiDi connection.
|
|
33
|
+
* @param {Array} browsingContextIds - An array of browsing context IDs that the network events will be subscribed to.
|
|
34
|
+
*/
|
|
22
35
|
constructor(driver, browsingContextIds) {
|
|
23
36
|
this._driver = driver
|
|
24
37
|
this._browsingContextIds = browsingContextIds
|
|
@@ -28,22 +41,52 @@ class Network {
|
|
|
28
41
|
this.bidi = await this._driver.getBidi()
|
|
29
42
|
}
|
|
30
43
|
|
|
44
|
+
/**
|
|
45
|
+
* Subscribes to the 'network.beforeRequestSent' event and handles it with the provided callback.
|
|
46
|
+
*
|
|
47
|
+
* @param {Function} callback - The callback function to handle the event.
|
|
48
|
+
* @returns {Promise<void>} - A promise that resolves when the subscription is successful.
|
|
49
|
+
*/
|
|
31
50
|
async beforeRequestSent(callback) {
|
|
32
51
|
await this.subscribeAndHandleEvent('network.beforeRequestSent', callback)
|
|
33
52
|
}
|
|
34
53
|
|
|
54
|
+
/**
|
|
55
|
+
* Subscribes to the 'network.responseStarted' event and handles it with the provided callback.
|
|
56
|
+
*
|
|
57
|
+
* @param {Function} callback - The callback function to handle the event.
|
|
58
|
+
* @returns {Promise<void>} - A promise that resolves when the subscription is successful.
|
|
59
|
+
*/
|
|
35
60
|
async responseStarted(callback) {
|
|
36
61
|
await this.subscribeAndHandleEvent('network.responseStarted', callback)
|
|
37
62
|
}
|
|
38
63
|
|
|
64
|
+
/**
|
|
65
|
+
* Subscribes to the 'network.responseCompleted' event and handles it with the provided callback.
|
|
66
|
+
*
|
|
67
|
+
* @param {Function} callback - The callback function to handle the event.
|
|
68
|
+
* @returns {Promise<void>} - A promise that resolves when the subscription is successful.
|
|
69
|
+
*/
|
|
39
70
|
async responseCompleted(callback) {
|
|
40
71
|
await this.subscribeAndHandleEvent('network.responseCompleted', callback)
|
|
41
72
|
}
|
|
42
73
|
|
|
74
|
+
/**
|
|
75
|
+
* Subscribes to the 'network.authRequired' event and handles it with the provided callback.
|
|
76
|
+
*
|
|
77
|
+
* @param {Function} callback - The callback function to handle the event.
|
|
78
|
+
* @returns {Promise<void>} - A promise that resolves when the subscription is successful.
|
|
79
|
+
*/
|
|
43
80
|
async authRequired(callback) {
|
|
44
81
|
await this.subscribeAndHandleEvent('network.authRequired', callback)
|
|
45
82
|
}
|
|
46
83
|
|
|
84
|
+
/**
|
|
85
|
+
* Subscribes to the 'network.fetchError' event and handles it with the provided callback.
|
|
86
|
+
*
|
|
87
|
+
* @param {Function} callback - The callback function to handle the event.
|
|
88
|
+
* @returns {Promise<void>} - A promise that resolves when the subscription is successful.
|
|
89
|
+
*/
|
|
47
90
|
async fetchError(callback) {
|
|
48
91
|
await this.subscribeAndHandleEvent('network.fetchError', callback)
|
|
49
92
|
}
|
|
@@ -92,19 +135,25 @@ class Network {
|
|
|
92
135
|
)
|
|
93
136
|
}
|
|
94
137
|
callback(response)
|
|
95
|
-
|
|
138
|
+
}
|
|
96
139
|
})
|
|
97
140
|
}
|
|
98
141
|
|
|
142
|
+
/**
|
|
143
|
+
* Adds a network intercept.
|
|
144
|
+
*
|
|
145
|
+
* @param {AddInterceptParameters} params - The parameters for the network intercept.
|
|
146
|
+
* @returns {Promise<string>} - A promise that resolves to the added intercept's id.
|
|
147
|
+
* @throws {Error} - If params is not an instance of AddInterceptParameters.
|
|
148
|
+
*/
|
|
99
149
|
async addIntercept(params) {
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
throw new Error(`Params must be an instance of AddInterceptParamenters. Received:'${params}'`)
|
|
150
|
+
if (!(params instanceof AddInterceptParameters)) {
|
|
151
|
+
throw new Error(`Params must be an instance of AddInterceptParameters. Received:'${params}'`)
|
|
103
152
|
}
|
|
104
153
|
|
|
105
154
|
const command = {
|
|
106
155
|
method: 'network.addIntercept',
|
|
107
|
-
params: Object.fromEntries(params.asMap())
|
|
156
|
+
params: Object.fromEntries(params.asMap()),
|
|
108
157
|
}
|
|
109
158
|
|
|
110
159
|
let response = await this.bidi.send(command)
|
|
@@ -112,61 +161,165 @@ class Network {
|
|
|
112
161
|
return response.result.intercept
|
|
113
162
|
}
|
|
114
163
|
|
|
164
|
+
/**
|
|
165
|
+
* Removes an intercept.
|
|
166
|
+
*
|
|
167
|
+
* @param {string} interceptId - The ID of the intercept to be removed.
|
|
168
|
+
* @returns {Promise<void>} - A promise that resolves when the intercept is successfully removed.
|
|
169
|
+
*/
|
|
115
170
|
async removeIntercept(interceptId) {
|
|
116
171
|
const command = {
|
|
117
172
|
method: 'network.removeIntercept',
|
|
118
|
-
params: {intercept: interceptId},
|
|
173
|
+
params: { intercept: interceptId },
|
|
119
174
|
}
|
|
120
175
|
|
|
121
176
|
await this.bidi.send(command)
|
|
122
177
|
}
|
|
123
178
|
|
|
179
|
+
/**
|
|
180
|
+
* Continues the network request with authentication credentials.
|
|
181
|
+
* @param {string} requestId - The ID of the request to continue.
|
|
182
|
+
* @param {string} username - The username for authentication.
|
|
183
|
+
* @param {string} password - The password for authentication.
|
|
184
|
+
* @returns {Promise<void>} - A promise that resolves when the command is sent.
|
|
185
|
+
*/
|
|
124
186
|
async continueWithAuth(requestId, username, password) {
|
|
125
187
|
const command = {
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
188
|
+
method: 'network.continueWithAuth',
|
|
189
|
+
params: {
|
|
190
|
+
request: requestId.toString(),
|
|
191
|
+
action: 'provideCredentials',
|
|
192
|
+
credentials: {
|
|
193
|
+
type: 'password',
|
|
194
|
+
username: username,
|
|
195
|
+
password: password,
|
|
196
|
+
},
|
|
197
|
+
},
|
|
198
|
+
}
|
|
199
|
+
await this.bidi.send(command)
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* Fails a network request.
|
|
204
|
+
*
|
|
205
|
+
* @param {number} requestId - The ID of the request to fail.
|
|
206
|
+
* @returns {Promise<void>} - A promise that resolves when the command is sent.
|
|
207
|
+
*/
|
|
208
|
+
async failRequest(requestId) {
|
|
209
|
+
const command = {
|
|
210
|
+
method: 'network.failRequest',
|
|
211
|
+
params: {
|
|
212
|
+
request: requestId.toString(),
|
|
213
|
+
},
|
|
214
|
+
}
|
|
137
215
|
await this.bidi.send(command)
|
|
138
216
|
}
|
|
139
217
|
|
|
218
|
+
/**
|
|
219
|
+
* Continues the network request with authentication but without providing credentials.
|
|
220
|
+
* @param {string} requestId - The ID of the request to continue with authentication.
|
|
221
|
+
* @returns {Promise<void>} - A promise that resolves when the command is sent.
|
|
222
|
+
*/
|
|
140
223
|
async continueWithAuthNoCredentials(requestId) {
|
|
141
224
|
const command = {
|
|
142
225
|
method: 'network.continueWithAuth',
|
|
143
226
|
params: {
|
|
144
227
|
request: requestId.toString(),
|
|
145
|
-
action: 'default'
|
|
228
|
+
action: 'default',
|
|
146
229
|
},
|
|
147
230
|
}
|
|
148
231
|
await this.bidi.send(command)
|
|
149
232
|
}
|
|
150
233
|
|
|
234
|
+
/**
|
|
235
|
+
* Cancels the authentication for a specific request.
|
|
236
|
+
*
|
|
237
|
+
* @param {string} requestId - The ID of the request to cancel authentication for.
|
|
238
|
+
* @returns {Promise<void>} - A promise that resolves when the command is sent.
|
|
239
|
+
*/
|
|
151
240
|
async cancelAuth(requestId) {
|
|
152
241
|
const command = {
|
|
153
242
|
method: 'network.continueWithAuth',
|
|
154
243
|
params: {
|
|
155
244
|
request: requestId.toString(),
|
|
156
|
-
action: 'cancel'
|
|
245
|
+
action: 'cancel',
|
|
157
246
|
},
|
|
158
247
|
}
|
|
159
248
|
await this.bidi.send(command)
|
|
160
249
|
}
|
|
161
250
|
|
|
251
|
+
/**
|
|
252
|
+
* Continues the network request with the provided parameters.
|
|
253
|
+
*
|
|
254
|
+
* @param {ContinueRequestParameters} params - The parameters for continuing the request.
|
|
255
|
+
* @throws {Error} If params is not an instance of ContinueRequestParameters.
|
|
256
|
+
* @returns {Promise<void>} A promise that resolves when the command is sent.
|
|
257
|
+
*/
|
|
258
|
+
async continueRequest(params) {
|
|
259
|
+
if (!(params instanceof ContinueRequestParameters)) {
|
|
260
|
+
throw new Error(`Params must be an instance of ContinueRequestParameters. Received:'${params}'`)
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
const command = {
|
|
264
|
+
method: 'network.continueRequest',
|
|
265
|
+
params: Object.fromEntries(params.asMap()),
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
await this.bidi.send(command)
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
/**
|
|
272
|
+
* Continues the network response with the given parameters.
|
|
273
|
+
*
|
|
274
|
+
* @param {ContinueResponseParameters} params - The parameters for continuing the response.
|
|
275
|
+
* @throws {Error} If params is not an instance of ContinueResponseParameters.
|
|
276
|
+
* @returns {Promise<void>} A promise that resolves when the command is sent.
|
|
277
|
+
*/
|
|
278
|
+
async continueResponse(params) {
|
|
279
|
+
if (!(params instanceof ContinueResponseParameters)) {
|
|
280
|
+
throw new Error(`Params must be an instance of ContinueResponseParameters. Received:'${params}'`)
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
const command = {
|
|
284
|
+
method: 'network.continueResponse',
|
|
285
|
+
params: Object.fromEntries(params.asMap()),
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
await this.bidi.send(command)
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
/**
|
|
292
|
+
* Provides a response for the network.
|
|
293
|
+
*
|
|
294
|
+
* @param {ProvideResponseParameters} params - The parameters for providing the response.
|
|
295
|
+
* @throws {Error} If params is not an instance of ProvideResponseParameters.
|
|
296
|
+
* @returns {Promise<void>} A promise that resolves when the command is sent.
|
|
297
|
+
*/
|
|
298
|
+
async provideResponse(params) {
|
|
299
|
+
if (!(params instanceof ProvideResponseParameters)) {
|
|
300
|
+
throw new Error(`Params must be an instance of ProvideResponseParameters. Received:'${params}'`)
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
const command = {
|
|
304
|
+
method: 'network.provideResponse',
|
|
305
|
+
params: Object.fromEntries(params.asMap()),
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
await this.bidi.send(command)
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
/**
|
|
312
|
+
* Unsubscribes from network events for all browsing contexts.
|
|
313
|
+
* @returns {Promise<void>} A promise that resolves when the network connection is closed.
|
|
314
|
+
*/
|
|
162
315
|
async close() {
|
|
163
316
|
await this.bidi.unsubscribe(
|
|
164
317
|
'network.beforeRequestSent',
|
|
165
318
|
'network.responseStarted',
|
|
166
319
|
'network.responseCompleted',
|
|
167
|
-
'network.authRequired'
|
|
320
|
+
'network.authRequired',
|
|
321
|
+
)
|
|
168
322
|
}
|
|
169
|
-
|
|
170
323
|
}
|
|
171
324
|
|
|
172
325
|
async function getNetworkInstance(driver, browsingContextIds = null) {
|