selenium-webdriver 4.9.0 → 4.9.2

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,15 @@
1
+ ## v4.9.2
2
+
3
+ #### :nail_care: Polish
4
+
5
+ * Handle rejection of the driver if not found
6
+
7
+ ## v4.9.1
8
+
9
+ #### :nail_care: Polish
10
+
11
+ * Add CDP files for v113 and remove v110
12
+
1
13
  ## v4.9.0
2
14
 
3
15
  #### :nail_care: Polish
@@ -70,7 +82,7 @@ fix: iedriver download with selenium-manager #11579
70
82
 
71
83
  #### Committers: 1
72
84
 
73
- - Potapov Dmitriy ([@potapovDim](https://github.com/potapovDim))
85
+ * Potapov Dmitriy ([@potapovDim](https://github.com/potapovDim))
74
86
 
75
87
  ## v4.7.0
76
88
 
@@ -91,7 +103,7 @@ fix: iedriver download with selenium-manager #11579
91
103
 
92
104
  #### :nail_care: Polish
93
105
 
94
- * Fix typos (#11258)
106
+ * Fix typos (#11258)
95
107
 
96
108
  ## v4.6.0
97
109
 
@@ -146,11 +158,12 @@ fix: iedriver download with selenium-manager #11579
146
158
  * destructuring exports
147
159
  * Moving from static to const to make js-dossier happy
148
160
  * Removing circular dependency Between webdriver.js and http.js
149
- * fix some typos in code and documentation
161
+ * fix some typos in code and documentation
150
162
  * add cdp v105 remove v102
151
163
  * add cdp v106 remove v103
152
164
 
153
165
  ## v4.4.0
166
+
154
167
  * Add support CDP 104 and remove CDP 101
155
168
 
156
169
  ## v4.3.1
@@ -1281,4 +1294,3 @@ major version release (i.e. 1.0.0).
1281
1294
  * Initial release for npm:
1282
1295
 
1283
1296
  npm install selenium-webdriver
1284
-
@@ -15,6 +15,7 @@
15
15
  // specific language governing permissions and limitations
16
16
  // under the License.
17
17
 
18
+ const { BrowsingContextInfo } = require('./browsingContextTypes')
18
19
  class BrowsingContext {
19
20
  constructor(driver) {
20
21
  this._driver = driver
@@ -145,31 +146,6 @@ class NavigateResult {
145
146
  }
146
147
  }
147
148
 
148
- class BrowsingContextInfo {
149
- constructor(id, url, children, parentBrowsingContext) {
150
- this._id = id
151
- this._url = url
152
- this._children = children
153
- this._parentBrowsingContext = parentBrowsingContext
154
- }
155
-
156
- get id() {
157
- return this._id
158
- }
159
-
160
- get url() {
161
- return this._url
162
- }
163
-
164
- get children() {
165
- return this._children
166
- }
167
-
168
- get parentBrowsingContext() {
169
- return this._parentBrowsingContext
170
- }
171
- }
172
-
173
149
  /**
174
150
  * initiate browsing context instance and return
175
151
  * @param driver
@@ -0,0 +1,95 @@
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 {
19
+ BrowsingContextInfo,
20
+ NavigationInfo,
21
+ } = require('./browsingContextTypes')
22
+
23
+ class BrowsingContextInspector {
24
+ constructor(driver, browsingContextIds) {
25
+ this._driver = driver
26
+ this._browsingContextIds = browsingContextIds
27
+ }
28
+
29
+ async init() {
30
+ this.bidi = await this._driver.getBidi()
31
+ }
32
+
33
+ async onBrowsingContextCreated(callback) {
34
+ await this.subscribeAndHandleEvent(
35
+ 'browsingContext.contextCreated',
36
+ callback
37
+ )
38
+ }
39
+
40
+ async onDomContentLoaded(callback) {
41
+ await this.subscribeAndHandleEvent(
42
+ 'browsingContext.domContentLoaded',
43
+ callback
44
+ )
45
+ }
46
+
47
+ async onBrowsingContextLoaded(callback) {
48
+ await this.subscribeAndHandleEvent('browsingContext.load', callback)
49
+ }
50
+
51
+ async subscribeAndHandleEvent(eventType, callback) {
52
+ if (this._browsingContextIds != null) {
53
+ await this.bidi.subscribe(eventType, this._browsingContextIds)
54
+ } else {
55
+ await this.bidi.subscribe(eventType)
56
+ }
57
+ this._on(callback)
58
+ }
59
+
60
+ async _on(callback) {
61
+ this.ws = await this.bidi.socket
62
+ this.ws.on('message', (event) => {
63
+ const { params } = JSON.parse(Buffer.from(event.toString()))
64
+ if (params) {
65
+ let response = null
66
+ if ('navigation' in params) {
67
+ response = new NavigationInfo(
68
+ params.context,
69
+ params.navigation,
70
+ params.timestamp,
71
+ params.url
72
+ )
73
+ } else if ('accepted' in params) {
74
+ /* Needs to be updated when browsers implement other events */
75
+ } else {
76
+ response = new BrowsingContextInfo(
77
+ params.context,
78
+ params.url,
79
+ params.children,
80
+ params.parent
81
+ )
82
+ }
83
+ callback(response)
84
+ }
85
+ })
86
+ }
87
+ }
88
+
89
+ async function getBrowsingContextInstance(driver, browsingContextIds = null) {
90
+ let instance = new BrowsingContextInspector(driver, browsingContextIds)
91
+ await instance.init()
92
+ return instance
93
+ }
94
+
95
+ module.exports = getBrowsingContextInstance
@@ -0,0 +1,52 @@
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
+ class BrowsingContextInfo {
19
+ constructor(id, url, children, parentBrowsingContext) {
20
+ this._id = id
21
+ this._url = url
22
+ this._children = children
23
+ this._parentBrowsingContext = parentBrowsingContext
24
+ }
25
+
26
+ get id() {
27
+ return this._id
28
+ }
29
+
30
+ get url() {
31
+ return this._url
32
+ }
33
+
34
+ get children() {
35
+ return this._children
36
+ }
37
+
38
+ get parentBrowsingContext() {
39
+ return this._parentBrowsingContext
40
+ }
41
+ }
42
+
43
+ class NavigationInfo {
44
+ constructor(browsingContextId, navigationId, timestamp, url) {
45
+ this.browsingContextId = browsingContextId
46
+ this.navigationId = navigationId
47
+ this.timestamp = timestamp
48
+ this.url = url
49
+ }
50
+ }
51
+
52
+ module.exports = { BrowsingContextInfo, NavigationInfo }
package/index.js CHANGED
@@ -41,6 +41,7 @@ const webdriver = require('./lib/webdriver')
41
41
  const select = require('./lib/select')
42
42
  const LogInspector = require('./bidi/logInspector')
43
43
  const BrowsingContext = require('./bidi/browsingContext')
44
+ const BrowsingConextInspector = require('./bidi/browsingContextInspector')
44
45
  const ScriptManager = require('./bidi/scriptManager')
45
46
 
46
47
  const Browser = capabilities.Browser
@@ -800,4 +801,5 @@ exports.until = until
800
801
  exports.Select = select.Select
801
802
  exports.LogInspector = LogInspector
802
803
  exports.BrowsingContext = BrowsingContext
804
+ exports.BrowsingConextInspector = BrowsingConextInspector
803
805
  exports.ScriptManager = ScriptManager
package/io/exec.js CHANGED
@@ -134,12 +134,16 @@ function exec(command, opt_options) {
134
134
  proc.unref()
135
135
  process.once('exit', onProcessExit)
136
136
 
137
- const result = new Promise((resolve) => {
137
+ const result = new Promise((resolve, reject) => {
138
138
  proc.once('exit', (code, signal) => {
139
139
  proc = null
140
140
  process.removeListener('exit', onProcessExit)
141
141
  resolve(new Result(code, signal))
142
142
  })
143
+
144
+ proc.once('error', err => {
145
+ reject(err);
146
+ })
143
147
  })
144
148
  return new Command(result, killCommand)
145
149
 
package/package.json CHANGED
@@ -1,7 +1,6 @@
1
-
2
1
  {
3
2
  "name": "selenium-webdriver",
4
- "version": "4.9.0",
3
+ "version": "4.9.2",
5
4
  "description": "The official WebDriver JavaScript bindings from the Selenium project",
6
5
  "license": "Apache-2.0",
7
6
  "keywords": [