selenium-webdriver 4.44.0 → 4.46.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.
Files changed (48) hide show
  1. package/CHANGES.md +20 -0
  2. package/bidi/browsingContextInspector.js +1 -1
  3. package/bidi/generated/bluetooth.d.ts +223 -0
  4. package/bidi/generated/bluetooth.js +154 -0
  5. package/bidi/generated/browser.d.ts +104 -0
  6. package/bidi/generated/browser.js +107 -0
  7. package/bidi/generated/browsing_context.d.ts +431 -0
  8. package/bidi/generated/browsing_context.js +280 -0
  9. package/bidi/generated/common.d.ts +38 -0
  10. package/bidi/generated/common.js +30 -0
  11. package/bidi/generated/emulation.d.ts +176 -0
  12. package/bidi/generated/emulation.js +133 -0
  13. package/bidi/generated/input.d.ts +151 -0
  14. package/bidi/generated/input.js +81 -0
  15. package/bidi/generated/log.d.ts +39 -0
  16. package/bidi/generated/log.js +67 -0
  17. package/bidi/generated/network.d.ts +359 -0
  18. package/bidi/generated/network.js +230 -0
  19. package/bidi/generated/permissions.d.ts +22 -0
  20. package/bidi/generated/permissions.js +43 -0
  21. package/bidi/generated/script.d.ts +410 -0
  22. package/bidi/generated/script.js +146 -0
  23. package/bidi/generated/session.d.ts +119 -0
  24. package/bidi/generated/session.js +82 -0
  25. package/bidi/generated/speculation.d.ts +17 -0
  26. package/bidi/generated/speculation.js +40 -0
  27. package/bidi/generated/storage.d.ts +84 -0
  28. package/bidi/generated/storage.js +70 -0
  29. package/bidi/generated/user_agent_client_hints.d.ts +33 -0
  30. package/bidi/generated/user_agent_client_hints.js +43 -0
  31. package/bidi/generated/webextension.d.ts +42 -0
  32. package/bidi/generated/webextension.js +53 -0
  33. package/bidi/index.js +24 -3
  34. package/bin/linux/selenium-manager +0 -0
  35. package/bin/macos/selenium-manager +0 -0
  36. package/bin/windows/selenium-manager.exe +0 -0
  37. package/common/driverFinder.js +2 -1
  38. package/common/seleniumManager.js +1 -1
  39. package/eslint.config.js +5 -5
  40. package/io/zip.js +1 -1
  41. package/lib/atoms/find-elements.js +272 -68
  42. package/lib/atoms/get-attribute.js +152 -17
  43. package/lib/atoms/is-displayed.js +385 -39
  44. package/lib/http.js +2 -1
  45. package/lib/pinnedScript.js +0 -1
  46. package/lib/until.js +7 -9
  47. package/lib/webdriver.js +2 -2
  48. package/package.json +17 -15
@@ -0,0 +1,230 @@
1
+ "use strict";
2
+ // Licensed to the Software Freedom Conservancy (SFC) under one
3
+ // or more contributor license agreements. See the NOTICE file
4
+ // distributed with this work for additional information
5
+ // regarding copyright ownership. The SFC licenses this file
6
+ // to you under the Apache License, Version 2.0 (the
7
+ // "License"); you may not use this file except in compliance
8
+ // with the License. You may obtain a copy of the License at
9
+ //
10
+ // http://www.apache.org/licenses/LICENSE-2.0
11
+ //
12
+ // Unless required by applicable law or agreed to in writing,
13
+ // software distributed under the License is distributed on an
14
+ // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
+ // KIND, either express or implied. See the License for the
16
+ // specific language governing permissions and limitations
17
+ // under the License.
18
+ Object.defineProperty(exports, "__esModule", { value: true });
19
+ exports.Network = void 0;
20
+ exports.getNetworkInstance = getNetworkInstance;
21
+ // --- Additional Types ---
22
+ /** @deprecated Use {@link Network.create} instead — will be removed in a future major version. */
23
+ async function getNetworkInstance(driver) {
24
+ return Network.create(driver);
25
+ }
26
+ // --- Implementation ---
27
+ class Network {
28
+ constructor(bidi) {
29
+ this.bidi = bidi;
30
+ }
31
+ static async create(driver) {
32
+ const caps = await driver.getCapabilities();
33
+ if (!caps.get('webSocketUrl')) {
34
+ throw new Error('WebDriver instance must support BiDi protocol');
35
+ }
36
+ const bidi = await driver.getBidi();
37
+ return new Network(bidi);
38
+ }
39
+ async addDataCollector(params) {
40
+ const response = await this.bidi.send({
41
+ method: 'network.addDataCollector',
42
+ params: params,
43
+ });
44
+ if (response['type'] === 'error') {
45
+ throw new Error(`${response['error']}: ${response['message']}`);
46
+ }
47
+ return response.result;
48
+ }
49
+ async addIntercept(params) {
50
+ const response = await this.bidi.send({
51
+ method: 'network.addIntercept',
52
+ params: params,
53
+ });
54
+ if (response['type'] === 'error') {
55
+ throw new Error(`${response['error']}: ${response['message']}`);
56
+ }
57
+ return response.result;
58
+ }
59
+ async continueRequest(params) {
60
+ const response = await this.bidi.send({
61
+ method: 'network.continueRequest',
62
+ params: params,
63
+ });
64
+ if (response['type'] === 'error') {
65
+ throw new Error(`${response['error']}: ${response['message']}`);
66
+ }
67
+ }
68
+ async continueResponse(params) {
69
+ const response = await this.bidi.send({
70
+ method: 'network.continueResponse',
71
+ params: params,
72
+ });
73
+ if (response['type'] === 'error') {
74
+ throw new Error(`${response['error']}: ${response['message']}`);
75
+ }
76
+ }
77
+ async continueWithAuth(paramsOrRequestId, username, password) {
78
+ let params;
79
+ if (typeof paramsOrRequestId === 'string') {
80
+ if (username === undefined || password === undefined) {
81
+ throw new Error('username and password are required when calling continueWithAuth with a request id');
82
+ }
83
+ params = {
84
+ request: paramsOrRequestId,
85
+ action: 'provideCredentials',
86
+ credentials: { type: 'password', username, password },
87
+ };
88
+ }
89
+ else {
90
+ params = paramsOrRequestId;
91
+ }
92
+ const response = await this.bidi.send({
93
+ method: 'network.continueWithAuth',
94
+ params: params,
95
+ });
96
+ if (response['type'] === 'error') {
97
+ throw new Error(`${response['error']}: ${response['message']}`);
98
+ }
99
+ }
100
+ async disownData(params) {
101
+ const response = await this.bidi.send({
102
+ method: 'network.disownData',
103
+ params: params,
104
+ });
105
+ if (response['type'] === 'error') {
106
+ throw new Error(`${response['error']}: ${response['message']}`);
107
+ }
108
+ }
109
+ async failRequest(params) {
110
+ const response = await this.bidi.send({
111
+ method: 'network.failRequest',
112
+ params: params,
113
+ });
114
+ if (response['type'] === 'error') {
115
+ throw new Error(`${response['error']}: ${response['message']}`);
116
+ }
117
+ }
118
+ async getData(params) {
119
+ const response = await this.bidi.send({
120
+ method: 'network.getData',
121
+ params: params,
122
+ });
123
+ if (response['type'] === 'error') {
124
+ throw new Error(`${response['error']}: ${response['message']}`);
125
+ }
126
+ return response.result;
127
+ }
128
+ async provideResponse(params) {
129
+ const response = await this.bidi.send({
130
+ method: 'network.provideResponse',
131
+ params: params,
132
+ });
133
+ if (response['type'] === 'error') {
134
+ throw new Error(`${response['error']}: ${response['message']}`);
135
+ }
136
+ }
137
+ async removeDataCollector(params) {
138
+ const response = await this.bidi.send({
139
+ method: 'network.removeDataCollector',
140
+ params: params,
141
+ });
142
+ if (response['type'] === 'error') {
143
+ throw new Error(`${response['error']}: ${response['message']}`);
144
+ }
145
+ }
146
+ async removeIntercept(params) {
147
+ const response = await this.bidi.send({
148
+ method: 'network.removeIntercept',
149
+ params: params,
150
+ });
151
+ if (response['type'] === 'error') {
152
+ throw new Error(`${response['error']}: ${response['message']}`);
153
+ }
154
+ }
155
+ async setCacheBehavior(params) {
156
+ const response = await this.bidi.send({
157
+ method: 'network.setCacheBehavior',
158
+ params: params,
159
+ });
160
+ if (response['type'] === 'error') {
161
+ throw new Error(`${response['error']}: ${response['message']}`);
162
+ }
163
+ }
164
+ async setExtraHeaders(params) {
165
+ const response = await this.bidi.send({
166
+ method: 'network.setExtraHeaders',
167
+ params: params,
168
+ });
169
+ if (response['type'] === 'error') {
170
+ throw new Error(`${response['error']}: ${response['message']}`);
171
+ }
172
+ }
173
+ async onAuthRequired(callback) {
174
+ await this.bidi.subscribe('network.authRequired');
175
+ this.bidi.on('network.authRequired', (params) => {
176
+ callback(params);
177
+ });
178
+ }
179
+ async onBeforeRequestSent(callback) {
180
+ await this.bidi.subscribe('network.beforeRequestSent');
181
+ this.bidi.on('network.beforeRequestSent', (params) => {
182
+ callback(params);
183
+ });
184
+ }
185
+ async onFetchError(callback) {
186
+ await this.bidi.subscribe('network.fetchError');
187
+ this.bidi.on('network.fetchError', (params) => {
188
+ callback(params);
189
+ });
190
+ }
191
+ async onResponseCompleted(callback) {
192
+ await this.bidi.subscribe('network.responseCompleted');
193
+ this.bidi.on('network.responseCompleted', (params) => {
194
+ callback(params);
195
+ });
196
+ }
197
+ async onResponseStarted(callback) {
198
+ await this.bidi.subscribe('network.responseStarted');
199
+ this.bidi.on('network.responseStarted', (params) => {
200
+ callback(params);
201
+ });
202
+ }
203
+ async cancelAuth(requestId) {
204
+ await this.continueWithAuth({ request: requestId, action: 'cancel' });
205
+ }
206
+ async continueWithAuthNoCredentials(requestId) {
207
+ await this.continueWithAuth({ request: requestId, action: 'default' });
208
+ }
209
+ /** @deprecated Use {@link onBeforeRequestSent} instead — will be removed in a future major version. */
210
+ async beforeRequestSent(callback) {
211
+ await this.onBeforeRequestSent(callback);
212
+ }
213
+ /** @deprecated Use {@link onAuthRequired} instead — will be removed in a future major version. */
214
+ async authRequired(callback) {
215
+ await this.onAuthRequired(callback);
216
+ }
217
+ /** @deprecated Use {@link onFetchError} instead — will be removed in a future major version. */
218
+ async fetchError(callback) {
219
+ await this.onFetchError(callback);
220
+ }
221
+ /** @deprecated Use {@link onResponseCompleted} instead — will be removed in a future major version. */
222
+ async responseCompleted(callback) {
223
+ await this.onResponseCompleted(callback);
224
+ }
225
+ /** @deprecated Use {@link onResponseStarted} instead — will be removed in a future major version. */
226
+ async responseStarted(callback) {
227
+ await this.onResponseStarted(callback);
228
+ }
229
+ }
230
+ exports.Network = Network;
@@ -0,0 +1,22 @@
1
+ export type PermissionsCommand = PermissionsSetPermission;
2
+ export interface PermissionsPermissionDescriptor {
3
+ name: string;
4
+ }
5
+ export type PermissionsPermissionState = "granted" | "denied" | "prompt";
6
+ export interface PermissionsSetPermission {
7
+ method: "permissions.setPermission";
8
+ params: PermissionsSetPermissionParameters;
9
+ }
10
+ export interface PermissionsSetPermissionParameters {
11
+ descriptor: PermissionsPermissionDescriptor;
12
+ state: PermissionsPermissionState;
13
+ origin: string;
14
+ embeddedOrigin?: string;
15
+ userContext?: string;
16
+ }
17
+ export declare class Permissions {
18
+ private readonly bidi;
19
+ private constructor();
20
+ static create(driver: unknown): Promise<Permissions>;
21
+ setPermission(params: PermissionsSetPermissionParameters): Promise<void>;
22
+ }
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ // Licensed to the Software Freedom Conservancy (SFC) under one
3
+ // or more contributor license agreements. See the NOTICE file
4
+ // distributed with this work for additional information
5
+ // regarding copyright ownership. The SFC licenses this file
6
+ // to you under the Apache License, Version 2.0 (the
7
+ // "License"); you may not use this file except in compliance
8
+ // with the License. You may obtain a copy of the License at
9
+ //
10
+ // http://www.apache.org/licenses/LICENSE-2.0
11
+ //
12
+ // Unless required by applicable law or agreed to in writing,
13
+ // software distributed under the License is distributed on an
14
+ // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
+ // KIND, either express or implied. See the License for the
16
+ // specific language governing permissions and limitations
17
+ // under the License.
18
+ Object.defineProperty(exports, "__esModule", { value: true });
19
+ exports.Permissions = void 0;
20
+ // --- Implementation ---
21
+ class Permissions {
22
+ constructor(bidi) {
23
+ this.bidi = bidi;
24
+ }
25
+ static async create(driver) {
26
+ const caps = await driver.getCapabilities();
27
+ if (!caps.get('webSocketUrl')) {
28
+ throw new Error('WebDriver instance must support BiDi protocol');
29
+ }
30
+ const bidi = await driver.getBidi();
31
+ return new Permissions(bidi);
32
+ }
33
+ async setPermission(params) {
34
+ const response = await this.bidi.send({
35
+ method: 'permissions.setPermission',
36
+ params: params,
37
+ });
38
+ if (response['type'] === 'error') {
39
+ throw new Error(`${response['error']}: ${response['message']}`);
40
+ }
41
+ }
42
+ }
43
+ exports.Permissions = Permissions;