selenium-webdriver 4.10.0 → 4.11.1

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 CHANGED
@@ -1,3 +1,35 @@
1
+ ## 4.11.1
2
+
3
+ #### :bug: Bug fix
4
+
5
+ * Update testing/index.js code snippet to fix function call (#12456)
6
+
7
+ ## v4.11.0
8
+
9
+ #### :nail_care: Polish
10
+
11
+ * [BiDi] fix addPreloadScript failing tests (#12182)
12
+ * Print debug message once for each browser when selenium manager used
13
+ * Add forgotten RelativeBy in check options (#12289)
14
+ * SM supports all browsers in Selenium since a while ago
15
+ * Using SM to check drivers on the PATH
16
+ * Display info about SM activity
17
+ * Removing logic to find drivers, delegating to Selenium Manager
18
+ * Removing service parameter from getPath
19
+ * add support for Chrome 115 and remove support for Chrome 112
20
+ * Update webdriver-bootstrap.js (#12276)
21
+
22
+ #### :rocket: New Feature
23
+
24
+ * [BiDi] add Network module events (#12197)
25
+ * Adding ignore process match for IE Mode across bindings (#12279)
26
+ * Add browser output from Selenium Manager to options (#12411)
27
+
28
+ #### :bug: Bug Fix
29
+
30
+ * fix SeleniumServer.start() crashes on MacOS with nodejs selenium-webdriver (#12158)
31
+ * Update by.js: Add forgotten RelativeBy in check options (#12289)
32
+
1
33
  ## v4.10.0
2
34
 
3
35
  #### :nail_care: Polish
@@ -1307,3 +1339,12 @@ major version release (i.e. 1.0.0).
1307
1339
  * Initial release for npm:
1308
1340
 
1309
1341
  npm install selenium-webdriver
1342
+
1343
+
1344
+
1345
+
1346
+
1347
+
1348
+
1349
+
1350
+
@@ -26,13 +26,13 @@ class BrowsingContext {
26
26
  throw Error('WebDriver instance must support BiDi protocol')
27
27
  }
28
28
 
29
- if (type != undefined && !['window', 'tab'].includes(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 == undefined
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 != undefined &&
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 browing context
120
+ * Closes the browsing context
121
121
  * @returns {Promise<void>}
122
122
  */
123
123
  async close() {
@@ -54,7 +54,7 @@ class BrowsingContextInspector {
54
54
  } else {
55
55
  await this.bidi.subscribe(eventType)
56
56
  }
57
- this._on(callback)
57
+ await this._on(callback)
58
58
  }
59
59
 
60
60
  async _on(callback) {
@@ -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 != undefined && !(filterBy instanceof 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 != undefined) {
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 != undefined && !(filterBy instanceof 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 != undefined) {
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 != undefined && !(filterBy instanceof 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 != undefined) {
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 != undefined) {
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 != undefined &&
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 != undefined) {
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