selenium-webdriver 4.9.2 → 4.11.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 +48 -0
- package/bidi/browsingContext.js +50 -4
- package/bidi/browsingContextInspector.js +1 -1
- package/bidi/logInspector.js +14 -11
- package/bidi/networkInspector.js +88 -0
- package/bidi/networkTypes.js +483 -0
- package/bidi/protocolValue.js +1 -1
- package/bidi/scriptManager.js +40 -6
- package/bin/linux/selenium-manager +0 -0
- package/bin/macos/selenium-manager +0 -0
- package/bin/windows/selenium-manager.exe +0 -0
- package/chrome.js +5 -25
- package/chromium.js +16 -5
- package/common/driverFinder.js +8 -23
- package/common/seleniumManager.js +50 -28
- package/edge.js +17 -25
- package/firefox.js +22 -27
- package/ie.js +4 -17
- package/index.js +2 -0
- package/io/exec.js +2 -2
- package/lib/atoms/find-elements.js +3 -4
- package/lib/by.js +1 -1
- package/lib/webdriver.js +2 -2
- package/package.json +5 -5
- package/remote/util.js +1 -3
- package/safari.js +6 -31
- package/testing/index.js +8 -7
package/CHANGES.md
CHANGED
|
@@ -1,3 +1,42 @@
|
|
|
1
|
+
## v4.11.0
|
|
2
|
+
|
|
3
|
+
#### :nail_care: Polish
|
|
4
|
+
|
|
5
|
+
* [BiDi] fix addPreloadScript failing tests (#12182)
|
|
6
|
+
* Print debug message once for each browser when selenium manager used
|
|
7
|
+
* Add forgotten RelativeBy in check options (#12289)
|
|
8
|
+
* SM supports all browsers in Selenium since a while ago
|
|
9
|
+
* Using SM to check drivers on the PATH
|
|
10
|
+
* Display info about SM activity
|
|
11
|
+
* Removing logic to find drivers, delegating to Selenium Manager
|
|
12
|
+
* Removing service parameter from getPath
|
|
13
|
+
* add support for Chrome 115 and remove support for Chrome 112
|
|
14
|
+
* Update webdriver-bootstrap.js (#12276)
|
|
15
|
+
|
|
16
|
+
#### :rocket: New Feature
|
|
17
|
+
|
|
18
|
+
* [BiDi] add Network module events (#12197)
|
|
19
|
+
* Adding ignore process match for IE Mode across bindings (#12279)
|
|
20
|
+
* Add browser output from Selenium Manager to options (#12411)
|
|
21
|
+
|
|
22
|
+
#### :bug: Bug Fix
|
|
23
|
+
|
|
24
|
+
* fix SeleniumServer.start() crashes on MacOS with nodejs selenium-webdriver (#12158)
|
|
25
|
+
* Update by.js: Add forgotten RelativeBy in check options (#12289)
|
|
26
|
+
|
|
27
|
+
## v4.10.0
|
|
28
|
+
|
|
29
|
+
#### :nail_care: Polish
|
|
30
|
+
|
|
31
|
+
* Adding CDP v114 and removing v111
|
|
32
|
+
|
|
33
|
+
#### :rocket: New Feature
|
|
34
|
+
|
|
35
|
+
* [Edge] Support webview2 (#11978)
|
|
36
|
+
* [BiDi] Add Script module commands to add/remove preloaded scripts (#11847)
|
|
37
|
+
* [BiDi] Add printPage command (#12124)
|
|
38
|
+
* Add support for proxies with Selenium Manager
|
|
39
|
+
|
|
1
40
|
## v4.9.2
|
|
2
41
|
|
|
3
42
|
#### :nail_care: Polish
|
|
@@ -1294,3 +1333,12 @@ major version release (i.e. 1.0.0).
|
|
|
1294
1333
|
* Initial release for npm:
|
|
1295
1334
|
|
|
1296
1335
|
npm install selenium-webdriver
|
|
1336
|
+
|
|
1337
|
+
|
|
1338
|
+
|
|
1339
|
+
|
|
1340
|
+
|
|
1341
|
+
|
|
1342
|
+
|
|
1343
|
+
|
|
1344
|
+
|
package/bidi/browsingContext.js
CHANGED
|
@@ -26,13 +26,13 @@ class BrowsingContext {
|
|
|
26
26
|
throw Error('WebDriver instance must support BiDi protocol')
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
if (type
|
|
29
|
+
if (type !== undefined && !['window', 'tab'].includes(type)) {
|
|
30
30
|
throw Error(`Valid types are 'window' & 'tab'. Received: ${type}`)
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
this.bidi = await this._driver.getBidi()
|
|
34
34
|
this._id =
|
|
35
|
-
browsingContextId
|
|
35
|
+
browsingContextId === undefined
|
|
36
36
|
? (await this.create(type, referenceContext))['result']['context']
|
|
37
37
|
: browsingContextId
|
|
38
38
|
}
|
|
@@ -65,7 +65,7 @@ class BrowsingContext {
|
|
|
65
65
|
*/
|
|
66
66
|
async navigate(url, readinessState = undefined) {
|
|
67
67
|
if (
|
|
68
|
-
readinessState
|
|
68
|
+
readinessState !== undefined &&
|
|
69
69
|
!['none', 'interactive', 'complete'].includes(readinessState)
|
|
70
70
|
) {
|
|
71
71
|
throw Error(
|
|
@@ -117,7 +117,7 @@ class BrowsingContext {
|
|
|
117
117
|
}
|
|
118
118
|
|
|
119
119
|
/**
|
|
120
|
-
* Closes the
|
|
120
|
+
* Closes the browsing context
|
|
121
121
|
* @returns {Promise<void>}
|
|
122
122
|
*/
|
|
123
123
|
async close() {
|
|
@@ -129,6 +129,42 @@ class BrowsingContext {
|
|
|
129
129
|
}
|
|
130
130
|
await this.bidi.send(params)
|
|
131
131
|
}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Prints PDF of the webpage
|
|
135
|
+
* @param options print options given by the user
|
|
136
|
+
* @returns PrintResult object
|
|
137
|
+
*/
|
|
138
|
+
async printPage(options = {}) {
|
|
139
|
+
let params = {
|
|
140
|
+
method: 'browsingContext.print',
|
|
141
|
+
// Setting default values for parameters
|
|
142
|
+
params: {
|
|
143
|
+
context: this._id,
|
|
144
|
+
background: false,
|
|
145
|
+
margin: {
|
|
146
|
+
bottom: 1.0,
|
|
147
|
+
left: 1.0,
|
|
148
|
+
right: 1.0,
|
|
149
|
+
top: 1.0,
|
|
150
|
+
},
|
|
151
|
+
orientation: 'portrait',
|
|
152
|
+
page: {
|
|
153
|
+
height: 27.94,
|
|
154
|
+
width: 21.59,
|
|
155
|
+
},
|
|
156
|
+
pageRanges: [],
|
|
157
|
+
scale: 1.0,
|
|
158
|
+
shrinkToFit: true,
|
|
159
|
+
},
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
// Updating parameter values based on the options passed
|
|
163
|
+
params.params = this._driver.validatePrintPageParams(options, params.params)
|
|
164
|
+
|
|
165
|
+
const response = await this.bidi.send(params)
|
|
166
|
+
return new PrintResult(response.result.data)
|
|
167
|
+
}
|
|
132
168
|
}
|
|
133
169
|
|
|
134
170
|
class NavigateResult {
|
|
@@ -146,6 +182,16 @@ class NavigateResult {
|
|
|
146
182
|
}
|
|
147
183
|
}
|
|
148
184
|
|
|
185
|
+
class PrintResult {
|
|
186
|
+
constructor(data) {
|
|
187
|
+
this._data = data
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
get data() {
|
|
191
|
+
return this._data
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
|
|
149
195
|
/**
|
|
150
196
|
* initiate browsing context instance and return
|
|
151
197
|
* @param driver
|
package/bidi/logInspector.js
CHANGED
|
@@ -54,10 +54,11 @@ class LogInspector {
|
|
|
54
54
|
/**
|
|
55
55
|
* Listen to Console logs
|
|
56
56
|
* @param callback
|
|
57
|
+
* @param filterBy
|
|
57
58
|
* @returns {Promise<void>}
|
|
58
59
|
*/
|
|
59
60
|
async onConsoleEntry(callback, filterBy = undefined) {
|
|
60
|
-
if (filterBy
|
|
61
|
+
if (filterBy !== undefined && !(filterBy instanceof FilterBy)) {
|
|
61
62
|
throw Error(`Pass valid FilterBy object. Received: ${filterBy}`)
|
|
62
63
|
}
|
|
63
64
|
|
|
@@ -78,7 +79,7 @@ class LogInspector {
|
|
|
78
79
|
params.stackTrace
|
|
79
80
|
)
|
|
80
81
|
|
|
81
|
-
if (filterBy
|
|
82
|
+
if (filterBy !== undefined) {
|
|
82
83
|
if (params?.level === filterBy.getLevel()) {
|
|
83
84
|
callback(consoleEntry)
|
|
84
85
|
}
|
|
@@ -93,10 +94,11 @@ class LogInspector {
|
|
|
93
94
|
/**
|
|
94
95
|
* Listen to JS logs
|
|
95
96
|
* @param callback
|
|
97
|
+
* @param filterBy
|
|
96
98
|
* @returns {Promise<void>}
|
|
97
99
|
*/
|
|
98
100
|
async onJavascriptLog(callback, filterBy = undefined) {
|
|
99
|
-
if (filterBy
|
|
101
|
+
if (filterBy !== undefined && !(filterBy instanceof FilterBy)) {
|
|
100
102
|
throw Error(`Pass valid FilterBy object. Received: ${filterBy}`)
|
|
101
103
|
}
|
|
102
104
|
|
|
@@ -114,7 +116,7 @@ class LogInspector {
|
|
|
114
116
|
params.stackTrace
|
|
115
117
|
)
|
|
116
118
|
|
|
117
|
-
if (filterBy
|
|
119
|
+
if (filterBy !== undefined) {
|
|
118
120
|
if (params?.level === filterBy.getLevel()) {
|
|
119
121
|
callback(jsEntry)
|
|
120
122
|
}
|
|
@@ -163,10 +165,11 @@ class LogInspector {
|
|
|
163
165
|
/**
|
|
164
166
|
* Listen to any logs
|
|
165
167
|
* @param callback
|
|
168
|
+
* @param filterBy
|
|
166
169
|
* @returns {Promise<void>}
|
|
167
170
|
*/
|
|
168
171
|
async onLog(callback, filterBy = undefined) {
|
|
169
|
-
if (filterBy
|
|
172
|
+
if (filterBy !== undefined && !(filterBy instanceof FilterBy)) {
|
|
170
173
|
throw Error(`Pass valid FilterBy object. Received: ${filterBy}`)
|
|
171
174
|
}
|
|
172
175
|
|
|
@@ -183,7 +186,7 @@ class LogInspector {
|
|
|
183
186
|
params.stackTrace
|
|
184
187
|
)
|
|
185
188
|
|
|
186
|
-
if (filterBy
|
|
189
|
+
if (filterBy !== undefined) {
|
|
187
190
|
if (params?.level === filterBy.getLevel()) {
|
|
188
191
|
callback(jsEntry)
|
|
189
192
|
}
|
|
@@ -193,7 +196,7 @@ class LogInspector {
|
|
|
193
196
|
callback(jsEntry)
|
|
194
197
|
return
|
|
195
198
|
}
|
|
196
|
-
|
|
199
|
+
|
|
197
200
|
if (params?.type === 'console') {
|
|
198
201
|
let consoleEntry = new ConsoleLogEntry(
|
|
199
202
|
params.level,
|
|
@@ -205,8 +208,8 @@ class LogInspector {
|
|
|
205
208
|
params.args,
|
|
206
209
|
params.stackTrace
|
|
207
210
|
)
|
|
208
|
-
|
|
209
|
-
if (filterBy
|
|
211
|
+
|
|
212
|
+
if (filterBy !== undefined) {
|
|
210
213
|
if (params?.level === filterBy.getLevel()) {
|
|
211
214
|
callback(consoleEntry)
|
|
212
215
|
}
|
|
@@ -218,7 +221,7 @@ class LogInspector {
|
|
|
218
221
|
}
|
|
219
222
|
|
|
220
223
|
if (
|
|
221
|
-
params
|
|
224
|
+
params !== undefined &&
|
|
222
225
|
!['console', 'javascript'].includes(params?.type)
|
|
223
226
|
) {
|
|
224
227
|
let genericEntry = new GenericLogEntry(
|
|
@@ -229,7 +232,7 @@ class LogInspector {
|
|
|
229
232
|
params.stackTrace
|
|
230
233
|
)
|
|
231
234
|
|
|
232
|
-
if (filterBy
|
|
235
|
+
if (filterBy !== undefined) {
|
|
233
236
|
if (params?.level === filterBy.getLevel()) {
|
|
234
237
|
callback(genericEntry)
|
|
235
238
|
}
|
|
@@ -0,0 +1,88 @@
|
|
|
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 { BeforeRequestSent, ResponseStarted } = require('./networkTypes')
|
|
19
|
+
|
|
20
|
+
class NetworkInspector {
|
|
21
|
+
constructor(driver, browsingContextIds) {
|
|
22
|
+
this._driver = driver
|
|
23
|
+
this._browsingContextIds = browsingContextIds
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
async init() {
|
|
27
|
+
this.bidi = await this._driver.getBidi()
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
async beforeRequestSent(callback) {
|
|
31
|
+
await this.subscribeAndHandleEvent('network.beforeRequestSent', callback)
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
async responseStarted(callback) {
|
|
35
|
+
await this.subscribeAndHandleEvent('network.responseStarted', callback)
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
async responseCompleted(callback) {
|
|
39
|
+
await this.subscribeAndHandleEvent('network.responseCompleted', callback)
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
async subscribeAndHandleEvent(eventType, callback) {
|
|
43
|
+
if (this._browsingContextIds != null) {
|
|
44
|
+
await this.bidi.subscribe(eventType, this._browsingContextIds)
|
|
45
|
+
} else {
|
|
46
|
+
await this.bidi.subscribe(eventType)
|
|
47
|
+
}
|
|
48
|
+
await this._on(callback)
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
async _on(callback) {
|
|
52
|
+
this.ws = await this.bidi.socket
|
|
53
|
+
this.ws.on('message', (event) => {
|
|
54
|
+
const { params } = JSON.parse(Buffer.from(event.toString()))
|
|
55
|
+
if (params) {
|
|
56
|
+
let response = null
|
|
57
|
+
if ('initiator' in params) {
|
|
58
|
+
response = new BeforeRequestSent(
|
|
59
|
+
params.context,
|
|
60
|
+
params.navigation,
|
|
61
|
+
params.redirectCount,
|
|
62
|
+
params.request,
|
|
63
|
+
params.timestamp,
|
|
64
|
+
params.initiator
|
|
65
|
+
)
|
|
66
|
+
} else if ('response' in params) {
|
|
67
|
+
response = new ResponseStarted(
|
|
68
|
+
params.context,
|
|
69
|
+
params.navigation,
|
|
70
|
+
params.redirectCount,
|
|
71
|
+
params.request,
|
|
72
|
+
params.timestamp,
|
|
73
|
+
params.response
|
|
74
|
+
)
|
|
75
|
+
}
|
|
76
|
+
callback(response)
|
|
77
|
+
}
|
|
78
|
+
})
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
async function getNetworkInspectorInstance(driver, browsingContextIds = null) {
|
|
83
|
+
let instance = new NetworkInspector(driver, browsingContextIds)
|
|
84
|
+
await instance.init()
|
|
85
|
+
return instance
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
module.exports = getNetworkInspectorInstance
|