selenium-webdriver 4.9.0 → 4.9.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 +6 -0
- package/bidi/browsingContext.js +1 -25
- package/bidi/browsingContextInspector.js +95 -0
- package/bidi/browsingContextTypes.js +52 -0
- package/index.js +2 -0
- package/package.json +1 -1
package/CHANGES.md
CHANGED
package/bidi/browsingContext.js
CHANGED
|
@@ -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
|