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/README.md
CHANGED
|
@@ -13,19 +13,18 @@ Selenium may be installed via npm with
|
|
|
13
13
|
You will need to download additional components to work with each of the major
|
|
14
14
|
browsers. The drivers for Chrome, Firefox, and Microsoft's IE and Edge web
|
|
15
15
|
browsers are all standalone executables that should be placed on your system
|
|
16
|
-
[PATH]. Apple's safaridriver (v10 and above) can be found at the
|
|
17
|
-
following path – /usr/bin/safaridriver. To enable automation on safari,
|
|
16
|
+
[PATH]. Apple's safaridriver (v10 and above) can be found at the
|
|
17
|
+
following path – /usr/bin/safaridriver. To enable automation on safari,
|
|
18
18
|
you need to run command `safaridriver --enable`.
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
|
|
|
22
|
-
|
|
23
|
-
|
|
|
24
|
-
|
|
|
25
|
-
|
|
|
26
|
-
|
|
|
27
|
-
|
|
|
28
|
-
| Safari | [safaridriver] |
|
|
20
|
+
| Browser | Component |
|
|
21
|
+
| :---------------- | :------------------------------- |
|
|
22
|
+
| Chrome | [chromedriver(.exe)][chrome] |
|
|
23
|
+
| Internet Explorer | [IEDriverServer.exe][release] |
|
|
24
|
+
| Edge | [MicrosoftWebDriver.msi][edge] |
|
|
25
|
+
| Firefox | [geckodriver(.exe)][geckodriver] |
|
|
26
|
+
| Opera | [operadriver(.exe)][operadriver] |
|
|
27
|
+
| Safari | [safaridriver] |
|
|
29
28
|
|
|
30
29
|
## Usage
|
|
31
30
|
|
|
@@ -33,18 +32,18 @@ The sample below and others are included in the `example` directory. You may
|
|
|
33
32
|
also find the tests for selenium-webdriver informative.
|
|
34
33
|
|
|
35
34
|
```javascript
|
|
36
|
-
const {Builder, Browser, By, Key, until} = require('selenium-webdriver')
|
|
35
|
+
const { Builder, Browser, By, Key, until } = require('selenium-webdriver')
|
|
37
36
|
|
|
38
|
-
(async function example() {
|
|
39
|
-
let driver = await new Builder().forBrowser(Browser.FIREFOX).build()
|
|
37
|
+
;(async function example() {
|
|
38
|
+
let driver = await new Builder().forBrowser(Browser.FIREFOX).build()
|
|
40
39
|
try {
|
|
41
|
-
await driver.get('https://www.google.com/ncr')
|
|
42
|
-
await driver.findElement(By.name('q')).sendKeys('webdriver', Key.RETURN)
|
|
43
|
-
await driver.wait(until.titleIs('webdriver - Google Search'), 1000)
|
|
40
|
+
await driver.get('https://www.google.com/ncr')
|
|
41
|
+
await driver.findElement(By.name('q')).sendKeys('webdriver', Key.RETURN)
|
|
42
|
+
await driver.wait(until.titleIs('webdriver - Google Search'), 1000)
|
|
44
43
|
} finally {
|
|
45
|
-
await driver.quit()
|
|
44
|
+
await driver.quit()
|
|
46
45
|
}
|
|
47
|
-
})()
|
|
46
|
+
})()
|
|
48
47
|
```
|
|
49
48
|
|
|
50
49
|
### Using the Builder API
|
|
@@ -55,15 +54,15 @@ the builder lets you set all options in one flow. When you call
|
|
|
55
54
|
`Builder#build()`, all options irrelevant to the selected browser are dropped:
|
|
56
55
|
|
|
57
56
|
```javascript
|
|
58
|
-
const webdriver = require('selenium-webdriver')
|
|
59
|
-
const chrome = require('selenium-webdriver/chrome')
|
|
60
|
-
const firefox = require('selenium-webdriver/firefox')
|
|
57
|
+
const webdriver = require('selenium-webdriver')
|
|
58
|
+
const chrome = require('selenium-webdriver/chrome')
|
|
59
|
+
const firefox = require('selenium-webdriver/firefox')
|
|
61
60
|
|
|
62
61
|
let driver = new webdriver.Builder()
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
62
|
+
.forBrowser(webdriver.Browser.FIREFOX)
|
|
63
|
+
.setChromeOptions(/* ... */)
|
|
64
|
+
.setFirefoxOptions(/* ... */)
|
|
65
|
+
.build()
|
|
67
66
|
```
|
|
68
67
|
|
|
69
68
|
Why would you want to configure options irrelevant to the target browser? The
|
|
@@ -99,10 +98,11 @@ API:
|
|
|
99
98
|
|
|
100
99
|
```javascript
|
|
101
100
|
let driver = new webdriver.Builder()
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
101
|
+
.forBrowser(webdriver.Browser.FIREFOX)
|
|
102
|
+
.usingServer('http://localhost:4444/wd/hub')
|
|
103
|
+
.build()
|
|
105
104
|
```
|
|
105
|
+
|
|
106
106
|
Or change the Builder's configuration at runtime with the `SELENIUM_REMOTE_URL`
|
|
107
107
|
environment variable:
|
|
108
108
|
|
|
@@ -135,82 +135,83 @@ will also have "best effort" support. Releases older than the latest LTS,
|
|
|
135
135
|
_semver-major_ releases, and all unstable release branches (e.g. "v.Next")
|
|
136
136
|
are considered strictly unsupported.
|
|
137
137
|
|
|
138
|
-
For example, suppose the current LTS and stable releases are v14.20.0 and
|
|
138
|
+
For example, suppose the current LTS and stable releases are v14.20.0 and
|
|
139
|
+
v18.8.0,
|
|
139
140
|
respectively. Then a Selenium release would have the following support levels:
|
|
140
141
|
|
|
141
|
-
| Version
|
|
142
|
-
|
|
143
|
-
|
|
|
144
|
-
| 14.20.0
|
|
145
|
-
|
|
|
146
|
-
|
|
|
147
|
-
| >= 18.8.0
|
|
148
|
-
|
|
|
142
|
+
| Version | Support |
|
|
143
|
+
| :-------: | :-----------: |
|
|
144
|
+
| <= 14.19 | _unsupported_ |
|
|
145
|
+
| 14.20.0 | supported |
|
|
146
|
+
| 18.0-7 | best effort |
|
|
147
|
+
| 18.8.0 | supported |
|
|
148
|
+
| >= 18.8.0 | best effort |
|
|
149
|
+
| v.Next | _unsupported_ |
|
|
149
150
|
|
|
150
151
|
### Support Level Definitions
|
|
151
152
|
|
|
152
153
|
- _supported:_ A selenium-webdriver release will be API compatible with the
|
|
153
|
-
|
|
154
|
+
platform API, without the use of runtime flags.
|
|
154
155
|
|
|
155
156
|
- _best effort:_ Bugs will be investigated as time permits. API compatibility is
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
157
|
+
only guaranteed where required by a _supported_ release. This effectively
|
|
158
|
+
means the adoption of new JS features, such as ES2015 modules, will depend
|
|
159
|
+
on what is supported in Node's LTS.
|
|
159
160
|
|
|
160
161
|
- _unsupported:_ Bug submissions will be closed as will-not-fix and API
|
|
161
|
-
|
|
162
|
+
compatibility is not guaranteed.
|
|
162
163
|
|
|
163
164
|
### Projected Support Schedule
|
|
164
165
|
|
|
165
166
|
If Node releases a new [LTS] each October and a new major version every 6
|
|
166
167
|
months, the support window for selenium-webdriver will be roughly:
|
|
167
168
|
|
|
168
|
-
|
|
|
169
|
-
|
|
170
|
-
|
|
|
171
|
-
|
|
|
172
|
-
|
|
|
173
|
-
|
|
|
174
|
-
|
|
|
169
|
+
| Release | Status | END-OF-LIFE |
|
|
170
|
+
| :-----: | :-------------: | :---------: |
|
|
171
|
+
| v14.x | Maintenance LTS | 2023-04-30 |
|
|
172
|
+
| v16.x | Active LTS | 2023-09-11 |
|
|
173
|
+
| v18.x | Current | 2025-04-30 |
|
|
174
|
+
| v19.x | Pending | 2023-06-01 |
|
|
175
|
+
| v20 | Pending | 2026-04-30 |
|
|
175
176
|
|
|
176
177
|
## Issues
|
|
177
178
|
|
|
178
179
|
Please report any issues using the [Selenium issue tracker][issues]. When using
|
|
179
180
|
the issue tracker
|
|
180
181
|
|
|
181
|
-
-
|
|
182
|
-
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
-
|
|
193
|
-
|
|
194
|
-
-
|
|
195
|
-
|
|
196
|
-
|
|
182
|
+
- **Do** include a detailed description of the problem.
|
|
183
|
+
- **Do** include a link to a [gist](http://gist.github.com/) with any
|
|
184
|
+
interesting stack traces/logs (you may also attach these directly to the bug
|
|
185
|
+
report).
|
|
186
|
+
- **Do** include a [reduced test case][reduction]. Reporting "unable to find
|
|
187
|
+
element on the page" is _not_ a valid report - there's nothing for us to
|
|
188
|
+
look into. Expect your bug report to be closed if you do not provide enough
|
|
189
|
+
information for us to investigate.
|
|
190
|
+
- **Do not** use the issue tracker to submit basic help requests. All help
|
|
191
|
+
inquiries should be directed to the [user forum][users] or #selenium IRC
|
|
192
|
+
channel.
|
|
193
|
+
- **Do not** post empty "I see this too" or "Any updates?" comments. These
|
|
194
|
+
provide no additional information and clutter the log.
|
|
195
|
+
- **Do not** report regressions on closed bugs as they are not actively
|
|
196
|
+
monitored for updates (especially bugs that are >6 months old). Please open a
|
|
197
|
+
new issue and reference the original bug in your report.
|
|
197
198
|
|
|
198
199
|
## License
|
|
199
200
|
|
|
200
201
|
Licensed to the Software Freedom Conservancy (SFC) under one
|
|
201
|
-
or more contributor license agreements.
|
|
202
|
+
or more contributor license agreements. See the NOTICE file
|
|
202
203
|
distributed with this work for additional information
|
|
203
|
-
regarding copyright ownership.
|
|
204
|
+
regarding copyright ownership. The SFC licenses this file
|
|
204
205
|
to you under the Apache License, Version 2.0 (the
|
|
205
206
|
"License"); you may not use this file except in compliance
|
|
206
|
-
with the License.
|
|
207
|
+
with the License. You may obtain a copy of the License at
|
|
207
208
|
|
|
208
209
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
209
210
|
|
|
210
211
|
Unless required by applicable law or agreed to in writing,
|
|
211
212
|
software distributed under the License is distributed on an
|
|
212
213
|
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
213
|
-
KIND, either express or implied.
|
|
214
|
+
KIND, either express or implied. See the License for the
|
|
214
215
|
specific language governing permissions and limitations
|
|
215
216
|
under the License.
|
|
216
217
|
|
|
@@ -223,9 +224,7 @@ under the License.
|
|
|
223
224
|
[edge]: http://go.microsoft.com/fwlink/?LinkId=619687
|
|
224
225
|
[geckodriver]: https://github.com/mozilla/geckodriver/releases/
|
|
225
226
|
[reduction]: http://www.webkit.org/quality/reduction.html
|
|
226
|
-
|
|
227
227
|
[release]: https://www.selenium.dev/downloads/
|
|
228
|
-
|
|
229
228
|
[users]: https://groups.google.com/forum/#!forum/selenium-users
|
|
230
229
|
[safaridriver]: https://developer.apple.com/library/prerelease/content/releasenotes/General/WhatsNewInSafari/Articles/Safari_10_0.html#//apple_ref/doc/uid/TP40014305-CH11-DontLinkElementID_28
|
|
231
230
|
[operadriver]: https://github.com/operasoftware/operachromiumdriver/releases
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
// specific language governing permissions and limitations
|
|
16
16
|
// under the License.
|
|
17
17
|
|
|
18
|
-
const {UrlPattern} = require(
|
|
18
|
+
const { UrlPattern } = require('./urlPattern')
|
|
19
19
|
|
|
20
20
|
class AddInterceptParameters {
|
|
21
21
|
#phases = []
|
|
@@ -23,64 +23,84 @@ class AddInterceptParameters {
|
|
|
23
23
|
|
|
24
24
|
constructor(phases) {
|
|
25
25
|
if (phases instanceof Array) {
|
|
26
|
-
phases.forEach(phase => this.#phases.push(phase))
|
|
26
|
+
phases.forEach((phase) => this.#phases.push(phase))
|
|
27
27
|
} else {
|
|
28
28
|
this.#phases.push(phases)
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
{
|
|
43
|
-
patterns.forEach(pattern => {
|
|
44
|
-
if (!pattern instanceof UrlPattern) {
|
|
45
|
-
throw new Error(`Pattern must be an instance of UrlPattern. Received:'${pattern}'`)
|
|
46
|
-
}
|
|
47
|
-
this.#urlPatterns.push(Object.fromEntries(pattern.asMap()))
|
|
48
|
-
})
|
|
49
|
-
return this
|
|
32
|
+
/**
|
|
33
|
+
* Adds a URL pattern to intercept.
|
|
34
|
+
*
|
|
35
|
+
* @param {UrlPattern} pattern - The URL pattern to add.
|
|
36
|
+
* @returns {AddInterceptParameters} - Returns the current instance of the class AddInterceptParameters for chaining.
|
|
37
|
+
* @throws {Error} - Throws an error if the pattern is not an instance of UrlPattern.
|
|
38
|
+
*/
|
|
39
|
+
urlPattern(pattern) {
|
|
40
|
+
if (!(pattern instanceof UrlPattern)) {
|
|
41
|
+
throw new Error(`Pattern must be an instance of UrlPattern. Received: '${pattern})'`)
|
|
50
42
|
}
|
|
43
|
+
this.#urlPatterns.push(Object.fromEntries(pattern.asMap()))
|
|
44
|
+
return this
|
|
45
|
+
}
|
|
51
46
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
47
|
+
/**
|
|
48
|
+
* Adds array of URL patterns to intercept.
|
|
49
|
+
*
|
|
50
|
+
* @param {UrlPattern[]} patterns - An array of UrlPattern instances representing the URL patterns to intercept.
|
|
51
|
+
* @returns {AddInterceptParameters} - Returns the instance of AddInterceptParameters for chaining.
|
|
52
|
+
* @throws {Error} - Throws an error if the pattern is not an instance of UrlPattern.
|
|
53
|
+
*/
|
|
54
|
+
urlPatterns(patterns) {
|
|
55
|
+
patterns.forEach((pattern) => {
|
|
56
|
+
if (!(pattern instanceof UrlPattern)) {
|
|
57
|
+
throw new Error(`Pattern must be an instance of UrlPattern. Received:'${pattern}'`)
|
|
56
58
|
}
|
|
59
|
+
this.#urlPatterns.push(Object.fromEntries(pattern.asMap()))
|
|
60
|
+
})
|
|
61
|
+
return this
|
|
62
|
+
}
|
|
57
63
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
this.#urlPatterns.push({'type': 'string', 'pattern': pattern})
|
|
69
|
-
})
|
|
70
|
-
return this
|
|
64
|
+
/**
|
|
65
|
+
* Adds string URL to intercept.
|
|
66
|
+
*
|
|
67
|
+
* @param {string} pattern - The URL pattern to be added.
|
|
68
|
+
* @returns {AddInterceptParameters} - Returns the instance of AddInterceptParameters for chaining..
|
|
69
|
+
* @throws {Error} - If the pattern is not an instance of String.
|
|
70
|
+
*/
|
|
71
|
+
urlStringPattern(pattern) {
|
|
72
|
+
if (typeof pattern !== 'string') {
|
|
73
|
+
throw new Error(`Pattern must be an instance of String. Received:'${pattern}'`)
|
|
71
74
|
}
|
|
72
75
|
|
|
76
|
+
this.#urlPatterns.push({ type: 'string', pattern: pattern })
|
|
77
|
+
return this
|
|
78
|
+
}
|
|
73
79
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
+
/**
|
|
81
|
+
* Adds array of string URLs to intercept.
|
|
82
|
+
* @param {string[]} patterns - An array of URL string patterns.
|
|
83
|
+
* @returns {this} - Returns the instance of AddInterceptParameters for chaining.
|
|
84
|
+
*/
|
|
85
|
+
urlStringPatterns(patterns) {
|
|
86
|
+
patterns.forEach((pattern) => {
|
|
87
|
+
if (typeof pattern !== 'string') {
|
|
88
|
+
throw new Error(`Pattern must be an instance of String. Received:'${pattern}'`)
|
|
80
89
|
}
|
|
90
|
+
this.#urlPatterns.push({ type: 'string', pattern: pattern })
|
|
91
|
+
})
|
|
92
|
+
return this
|
|
93
|
+
}
|
|
81
94
|
|
|
82
|
-
|
|
95
|
+
asMap() {
|
|
96
|
+
const map = new Map()
|
|
97
|
+
map.set('phases', this.#phases)
|
|
98
|
+
if (this.#urlPatterns.length > 0) {
|
|
99
|
+
map.set('urlPatterns', this.#urlPatterns)
|
|
83
100
|
}
|
|
101
|
+
|
|
102
|
+
return map
|
|
84
103
|
}
|
|
104
|
+
}
|
|
85
105
|
|
|
86
|
-
|
|
106
|
+
module.exports = { AddInterceptParameters }
|
package/bidi/argumentValue.js
CHANGED
package/bidi/browser.js
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
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
|
+
/**
|
|
19
|
+
* Represents the commands and events under Browser Module.
|
|
20
|
+
* Described in https://w3c.github.io/webdriver-bidi/#module-browser
|
|
21
|
+
*/
|
|
22
|
+
class Browser {
|
|
23
|
+
constructor(driver) {
|
|
24
|
+
this._driver = driver
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
async init() {
|
|
28
|
+
if (!(await this._driver.getCapabilities()).get('webSocketUrl')) {
|
|
29
|
+
throw Error('WebDriver instance must support BiDi protocol')
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
this.bidi = await this._driver.getBidi()
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Creates a new user context.
|
|
37
|
+
* @returns {Promise<string>} A promise that resolves to the user context id.
|
|
38
|
+
*/
|
|
39
|
+
async createUserContext() {
|
|
40
|
+
const command = {
|
|
41
|
+
method: 'browser.createUserContext',
|
|
42
|
+
params: {},
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
let response = await this.bidi.send(command)
|
|
46
|
+
|
|
47
|
+
return response.result.userContext
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Gets the list of all user contexts.
|
|
52
|
+
* @returns {Promise<string[]>} A promise that resolves to an array of user context ids.
|
|
53
|
+
*/
|
|
54
|
+
async getUserContexts() {
|
|
55
|
+
const command = {
|
|
56
|
+
method: 'browser.getUserContexts',
|
|
57
|
+
params: {},
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
let response = await this.bidi.send(command)
|
|
61
|
+
|
|
62
|
+
let userContexts = []
|
|
63
|
+
|
|
64
|
+
let userContextsArray = response.result.userContexts
|
|
65
|
+
|
|
66
|
+
for (let userContextJson of userContextsArray) {
|
|
67
|
+
userContexts.push(userContextJson.userContext)
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return userContexts
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Removes a user context.
|
|
75
|
+
* @param {string} userContext The user context id to be removed.
|
|
76
|
+
* @returns {Promise<void>}
|
|
77
|
+
*/
|
|
78
|
+
async removeUserContext(userContext) {
|
|
79
|
+
const command = {
|
|
80
|
+
method: 'browser.removeUserContext',
|
|
81
|
+
params: { userContext: userContext },
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
await this.bidi.send(command)
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
async function getBrowserInstance(driver) {
|
|
89
|
+
let instance = new Browser(driver)
|
|
90
|
+
await instance.init()
|
|
91
|
+
return instance
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
module.exports = getBrowserInstance
|