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.
- package/CHANGES.md +20 -0
- package/bidi/browsingContextInspector.js +1 -1
- package/bidi/generated/bluetooth.d.ts +223 -0
- package/bidi/generated/bluetooth.js +154 -0
- package/bidi/generated/browser.d.ts +104 -0
- package/bidi/generated/browser.js +107 -0
- package/bidi/generated/browsing_context.d.ts +431 -0
- package/bidi/generated/browsing_context.js +280 -0
- package/bidi/generated/common.d.ts +38 -0
- package/bidi/generated/common.js +30 -0
- package/bidi/generated/emulation.d.ts +176 -0
- package/bidi/generated/emulation.js +133 -0
- package/bidi/generated/input.d.ts +151 -0
- package/bidi/generated/input.js +81 -0
- package/bidi/generated/log.d.ts +39 -0
- package/bidi/generated/log.js +67 -0
- package/bidi/generated/network.d.ts +359 -0
- package/bidi/generated/network.js +230 -0
- package/bidi/generated/permissions.d.ts +22 -0
- package/bidi/generated/permissions.js +43 -0
- package/bidi/generated/script.d.ts +410 -0
- package/bidi/generated/script.js +146 -0
- package/bidi/generated/session.d.ts +119 -0
- package/bidi/generated/session.js +82 -0
- package/bidi/generated/speculation.d.ts +17 -0
- package/bidi/generated/speculation.js +40 -0
- package/bidi/generated/storage.d.ts +84 -0
- package/bidi/generated/storage.js +70 -0
- package/bidi/generated/user_agent_client_hints.d.ts +33 -0
- package/bidi/generated/user_agent_client_hints.js +43 -0
- package/bidi/generated/webextension.d.ts +42 -0
- package/bidi/generated/webextension.js +53 -0
- package/bidi/index.js +24 -3
- package/bin/linux/selenium-manager +0 -0
- package/bin/macos/selenium-manager +0 -0
- package/bin/windows/selenium-manager.exe +0 -0
- package/common/driverFinder.js +2 -1
- package/common/seleniumManager.js +1 -1
- package/eslint.config.js +5 -5
- package/io/zip.js +1 -1
- package/lib/atoms/find-elements.js +272 -68
- package/lib/atoms/get-attribute.js +152 -17
- package/lib/atoms/is-displayed.js +385 -39
- package/lib/http.js +2 -1
- package/lib/pinnedScript.js +0 -1
- package/lib/until.js +7 -9
- package/lib/webdriver.js +2 -2
- package/package.json +17 -15
|
@@ -0,0 +1,280 @@
|
|
|
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.BrowsingContext = void 0;
|
|
20
|
+
exports.getBrowsingContextInstance = getBrowsingContextInstance;
|
|
21
|
+
// --- Additional Types ---
|
|
22
|
+
/** @deprecated Use {@link BrowsingContext.create} instead — will be removed in a future major version. */
|
|
23
|
+
async function getBrowsingContextInstance(driver) {
|
|
24
|
+
return BrowsingContext.create(driver);
|
|
25
|
+
}
|
|
26
|
+
// --- Implementation ---
|
|
27
|
+
class BrowsingContext {
|
|
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 BrowsingContext(bidi);
|
|
38
|
+
}
|
|
39
|
+
async activate(params) {
|
|
40
|
+
const response = await this.bidi.send({
|
|
41
|
+
method: 'browsingContext.activate',
|
|
42
|
+
params: params,
|
|
43
|
+
});
|
|
44
|
+
if (response['type'] === 'error') {
|
|
45
|
+
throw new Error(`${response['error']}: ${response['message']}`);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
async captureScreenshot(params) {
|
|
49
|
+
const response = await this.bidi.send({
|
|
50
|
+
method: 'browsingContext.captureScreenshot',
|
|
51
|
+
params: params,
|
|
52
|
+
});
|
|
53
|
+
if (response['type'] === 'error') {
|
|
54
|
+
throw new Error(`${response['error']}: ${response['message']}`);
|
|
55
|
+
}
|
|
56
|
+
return response.result;
|
|
57
|
+
}
|
|
58
|
+
async close(params) {
|
|
59
|
+
const response = await this.bidi.send({
|
|
60
|
+
method: 'browsingContext.close',
|
|
61
|
+
params: params,
|
|
62
|
+
});
|
|
63
|
+
if (response['type'] === 'error') {
|
|
64
|
+
throw new Error(`${response['error']}: ${response['message']}`);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
async create(params) {
|
|
68
|
+
const response = await this.bidi.send({
|
|
69
|
+
method: 'browsingContext.create',
|
|
70
|
+
params: params,
|
|
71
|
+
});
|
|
72
|
+
if (response['type'] === 'error') {
|
|
73
|
+
throw new Error(`${response['error']}: ${response['message']}`);
|
|
74
|
+
}
|
|
75
|
+
return response.result;
|
|
76
|
+
}
|
|
77
|
+
async getTree(params) {
|
|
78
|
+
const response = await this.bidi.send({
|
|
79
|
+
method: 'browsingContext.getTree',
|
|
80
|
+
params: params,
|
|
81
|
+
});
|
|
82
|
+
if (response['type'] === 'error') {
|
|
83
|
+
throw new Error(`${response['error']}: ${response['message']}`);
|
|
84
|
+
}
|
|
85
|
+
return response.result;
|
|
86
|
+
}
|
|
87
|
+
async handleUserPrompt(params) {
|
|
88
|
+
const response = await this.bidi.send({
|
|
89
|
+
method: 'browsingContext.handleUserPrompt',
|
|
90
|
+
params: params,
|
|
91
|
+
});
|
|
92
|
+
if (response['type'] === 'error') {
|
|
93
|
+
throw new Error(`${response['error']}: ${response['message']}`);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
async locateNodes(params) {
|
|
97
|
+
const response = await this.bidi.send({
|
|
98
|
+
method: 'browsingContext.locateNodes',
|
|
99
|
+
params: params,
|
|
100
|
+
});
|
|
101
|
+
if (response['type'] === 'error') {
|
|
102
|
+
throw new Error(`${response['error']}: ${response['message']}`);
|
|
103
|
+
}
|
|
104
|
+
return response.result;
|
|
105
|
+
}
|
|
106
|
+
async navigate(params) {
|
|
107
|
+
const response = await this.bidi.send({
|
|
108
|
+
method: 'browsingContext.navigate',
|
|
109
|
+
params: params,
|
|
110
|
+
});
|
|
111
|
+
if (response['type'] === 'error') {
|
|
112
|
+
throw new Error(`${response['error']}: ${response['message']}`);
|
|
113
|
+
}
|
|
114
|
+
return response.result;
|
|
115
|
+
}
|
|
116
|
+
async print(params) {
|
|
117
|
+
const response = await this.bidi.send({
|
|
118
|
+
method: 'browsingContext.print',
|
|
119
|
+
params: params,
|
|
120
|
+
});
|
|
121
|
+
if (response['type'] === 'error') {
|
|
122
|
+
throw new Error(`${response['error']}: ${response['message']}`);
|
|
123
|
+
}
|
|
124
|
+
return response.result;
|
|
125
|
+
}
|
|
126
|
+
async reload(params) {
|
|
127
|
+
const response = await this.bidi.send({
|
|
128
|
+
method: 'browsingContext.reload',
|
|
129
|
+
params: params,
|
|
130
|
+
});
|
|
131
|
+
if (response['type'] === 'error') {
|
|
132
|
+
throw new Error(`${response['error']}: ${response['message']}`);
|
|
133
|
+
}
|
|
134
|
+
return response.result;
|
|
135
|
+
}
|
|
136
|
+
async setBypassCSP(params) {
|
|
137
|
+
const response = await this.bidi.send({
|
|
138
|
+
method: 'browsingContext.setBypassCSP',
|
|
139
|
+
params: params,
|
|
140
|
+
});
|
|
141
|
+
if (response['type'] === 'error') {
|
|
142
|
+
throw new Error(`${response['error']}: ${response['message']}`);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
async setViewport(params) {
|
|
146
|
+
const response = await this.bidi.send({
|
|
147
|
+
method: 'browsingContext.setViewport',
|
|
148
|
+
params: params,
|
|
149
|
+
});
|
|
150
|
+
if (response['type'] === 'error') {
|
|
151
|
+
throw new Error(`${response['error']}: ${response['message']}`);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
async startScreencast(params) {
|
|
155
|
+
const response = await this.bidi.send({
|
|
156
|
+
method: 'browsingContext.startScreencast',
|
|
157
|
+
params: params,
|
|
158
|
+
});
|
|
159
|
+
if (response['type'] === 'error') {
|
|
160
|
+
throw new Error(`${response['error']}: ${response['message']}`);
|
|
161
|
+
}
|
|
162
|
+
return response.result;
|
|
163
|
+
}
|
|
164
|
+
async stopScreencast(params) {
|
|
165
|
+
const response = await this.bidi.send({
|
|
166
|
+
method: 'browsingContext.stopScreencast',
|
|
167
|
+
params: params,
|
|
168
|
+
});
|
|
169
|
+
if (response['type'] === 'error') {
|
|
170
|
+
throw new Error(`${response['error']}: ${response['message']}`);
|
|
171
|
+
}
|
|
172
|
+
return response.result;
|
|
173
|
+
}
|
|
174
|
+
async traverseHistory(params) {
|
|
175
|
+
const response = await this.bidi.send({
|
|
176
|
+
method: 'browsingContext.traverseHistory',
|
|
177
|
+
params: params,
|
|
178
|
+
});
|
|
179
|
+
if (response['type'] === 'error') {
|
|
180
|
+
throw new Error(`${response['error']}: ${response['message']}`);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
async onContextCreated(callback) {
|
|
184
|
+
await this.bidi.subscribe('browsingContext.contextCreated');
|
|
185
|
+
this.bidi.on('browsingContext.contextCreated', (params) => {
|
|
186
|
+
callback(params);
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
async onContextDestroyed(callback) {
|
|
190
|
+
await this.bidi.subscribe('browsingContext.contextDestroyed');
|
|
191
|
+
this.bidi.on('browsingContext.contextDestroyed', (params) => {
|
|
192
|
+
callback(params);
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
async onDomContentLoaded(callback) {
|
|
196
|
+
await this.bidi.subscribe('browsingContext.domContentLoaded');
|
|
197
|
+
this.bidi.on('browsingContext.domContentLoaded', (params) => {
|
|
198
|
+
callback(params);
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
async onDownloadEnd(callback) {
|
|
202
|
+
await this.bidi.subscribe('browsingContext.downloadEnd');
|
|
203
|
+
this.bidi.on('browsingContext.downloadEnd', (params) => {
|
|
204
|
+
callback(params);
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
async onDownloadWillBegin(callback) {
|
|
208
|
+
await this.bidi.subscribe('browsingContext.downloadWillBegin');
|
|
209
|
+
this.bidi.on('browsingContext.downloadWillBegin', (params) => {
|
|
210
|
+
callback(params);
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
async onFragmentNavigated(callback) {
|
|
214
|
+
await this.bidi.subscribe('browsingContext.fragmentNavigated');
|
|
215
|
+
this.bidi.on('browsingContext.fragmentNavigated', (params) => {
|
|
216
|
+
callback(params);
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
async onHistoryUpdated(callback) {
|
|
220
|
+
await this.bidi.subscribe('browsingContext.historyUpdated');
|
|
221
|
+
this.bidi.on('browsingContext.historyUpdated', (params) => {
|
|
222
|
+
callback(params);
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
async onLoad(callback) {
|
|
226
|
+
await this.bidi.subscribe('browsingContext.load');
|
|
227
|
+
this.bidi.on('browsingContext.load', (params) => {
|
|
228
|
+
callback(params);
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
async onNavigationAborted(callback) {
|
|
232
|
+
await this.bidi.subscribe('browsingContext.navigationAborted');
|
|
233
|
+
this.bidi.on('browsingContext.navigationAborted', (params) => {
|
|
234
|
+
callback(params);
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
async onNavigationCommitted(callback) {
|
|
238
|
+
await this.bidi.subscribe('browsingContext.navigationCommitted');
|
|
239
|
+
this.bidi.on('browsingContext.navigationCommitted', (params) => {
|
|
240
|
+
callback(params);
|
|
241
|
+
});
|
|
242
|
+
}
|
|
243
|
+
async onNavigationFailed(callback) {
|
|
244
|
+
await this.bidi.subscribe('browsingContext.navigationFailed');
|
|
245
|
+
this.bidi.on('browsingContext.navigationFailed', (params) => {
|
|
246
|
+
callback(params);
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
async onNavigationStarted(callback) {
|
|
250
|
+
await this.bidi.subscribe('browsingContext.navigationStarted');
|
|
251
|
+
this.bidi.on('browsingContext.navigationStarted', (params) => {
|
|
252
|
+
callback(params);
|
|
253
|
+
});
|
|
254
|
+
}
|
|
255
|
+
async onUserPromptClosed(callback) {
|
|
256
|
+
await this.bidi.subscribe('browsingContext.userPromptClosed');
|
|
257
|
+
this.bidi.on('browsingContext.userPromptClosed', (params) => {
|
|
258
|
+
callback(params);
|
|
259
|
+
});
|
|
260
|
+
}
|
|
261
|
+
async onUserPromptOpened(callback) {
|
|
262
|
+
await this.bidi.subscribe('browsingContext.userPromptOpened');
|
|
263
|
+
this.bidi.on('browsingContext.userPromptOpened', (params) => {
|
|
264
|
+
callback(params);
|
|
265
|
+
});
|
|
266
|
+
}
|
|
267
|
+
async back(context) {
|
|
268
|
+
await this.traverseHistory({ context, delta: -1 });
|
|
269
|
+
}
|
|
270
|
+
async forward(context) {
|
|
271
|
+
await this.traverseHistory({ context, delta: 1 });
|
|
272
|
+
}
|
|
273
|
+
async getTopLevelContexts() {
|
|
274
|
+
return this.getTree({});
|
|
275
|
+
}
|
|
276
|
+
async printPage(params) {
|
|
277
|
+
return this.print(params);
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
exports.BrowsingContext = BrowsingContext;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { BrowserCommand, BrowserResult } from './browser.js';
|
|
2
|
+
import type { BrowsingContextCommand, BrowsingContextEvent, BrowsingContextResult } from './browsing_context.js';
|
|
3
|
+
import type { EmulationCommand, EmulationResult } from './emulation.js';
|
|
4
|
+
import type { InputCommand, InputEvent, InputResult } from './input.js';
|
|
5
|
+
import type { LogEvent } from './log.js';
|
|
6
|
+
import type { NetworkCommand, NetworkEvent, NetworkResult } from './network.js';
|
|
7
|
+
import type { ScriptCommand, ScriptEvent, ScriptResult } from './script.js';
|
|
8
|
+
import type { SessionCommand, SessionResult } from './session.js';
|
|
9
|
+
import type { StorageCommand, StorageResult } from './storage.js';
|
|
10
|
+
import type { WebExtensionCommand, WebExtensionResult } from './webextension.js';
|
|
11
|
+
export type Command = CommandData & Extensible & {
|
|
12
|
+
id: JsUint;
|
|
13
|
+
};
|
|
14
|
+
export type CommandData = BrowserCommand | BrowsingContextCommand | EmulationCommand | InputCommand | NetworkCommand | ScriptCommand | SessionCommand | StorageCommand | WebExtensionCommand;
|
|
15
|
+
export type EmptyParams = Extensible;
|
|
16
|
+
export type Message = CommandResponse | ErrorResponse | Event;
|
|
17
|
+
export type CommandResponse = Extensible & {
|
|
18
|
+
type: "success";
|
|
19
|
+
id: JsUint;
|
|
20
|
+
result: ResultData;
|
|
21
|
+
};
|
|
22
|
+
export type ErrorResponse = Extensible & {
|
|
23
|
+
type: "error";
|
|
24
|
+
id: JsUint | null;
|
|
25
|
+
error: ErrorCode;
|
|
26
|
+
message: string;
|
|
27
|
+
stacktrace?: string;
|
|
28
|
+
};
|
|
29
|
+
export type ResultData = BrowserResult | BrowsingContextResult | EmulationResult | InputResult | NetworkResult | ScriptResult | SessionResult | StorageResult | WebExtensionResult;
|
|
30
|
+
export type EmptyResult = Extensible;
|
|
31
|
+
export type Event = EventData & Extensible & {
|
|
32
|
+
type: "event";
|
|
33
|
+
};
|
|
34
|
+
export type EventData = BrowsingContextEvent | InputEvent | LogEvent | NetworkEvent | ScriptEvent;
|
|
35
|
+
export type Extensible = Record<string, unknown>;
|
|
36
|
+
export type JsInt = number;
|
|
37
|
+
export type JsUint = number;
|
|
38
|
+
export type ErrorCode = "invalid argument" | "invalid selector" | "invalid session id" | "invalid web extension" | "move target out of bounds" | "no such alert" | "no such network collector" | "no such element" | "no such frame" | "no such handle" | "no such history entry" | "no such intercept" | "no such network data" | "no such node" | "no such request" | "no such screencast" | "no such script" | "no such storage partition" | "no such user context" | "no such web extension" | "session not created" | "unable to capture screen" | "unable to close browser" | "unable to set cookie" | "unable to set file input" | "unavailable network data" | "underspecified storage partition" | "unknown command" | "unknown error" | "unsupported operation";
|
|
@@ -0,0 +1,30 @@
|
|
|
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
|
+
// Minimum size is 1pt x 1pt. Conversion follows from
|
|
20
|
+
// https://www.w3.org/TR/css3-values/#absolute-lengths
|
|
21
|
+
// Minimum size is 1pt x 1pt. Conversion follows from
|
|
22
|
+
// https://www.w3.org/TR/css3-values/#absolute-lengths
|
|
23
|
+
// Content was automatically extracted by Reffy into webref
|
|
24
|
+
// (https://github.com/w3c/webref)
|
|
25
|
+
// Content was automatically extracted by Reffy into webref
|
|
26
|
+
// (https://github.com/w3c/webref)
|
|
27
|
+
// Content was automatically extracted by Reffy into webref
|
|
28
|
+
// (https://github.com/w3c/webref)
|
|
29
|
+
// Content was automatically extracted by Reffy into webref
|
|
30
|
+
// (https://github.com/w3c/webref)
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import type { BrowserUserContext } from './browser.js';
|
|
2
|
+
import type { BrowsingContextBrowsingContext } from './browsing_context.js';
|
|
3
|
+
import type { EmptyResult, JsUint } from './common.js';
|
|
4
|
+
export type EmulationCommand = EmulationSetForcedColorsModeThemeOverride | EmulationSetGeolocationOverride | EmulationSetLocaleOverride | EmulationSetNetworkConditions | EmulationSetScreenOrientationOverride | EmulationSetScreenSettingsOverride | EmulationSetScriptingEnabled | EmulationSetScrollbarTypeOverride | EmulationSetTimezoneOverride | EmulationSetTouchOverride | EmulationSetUserAgentOverride;
|
|
5
|
+
export type EmulationResult = EmulationSetForcedColorsModeThemeOverrideResult | EmulationSetGeolocationOverrideResult | EmulationSetLocaleOverrideResult | EmulationSetScreenOrientationOverrideResult | EmulationSetScriptingEnabledResult | EmulationSetScrollbarTypeOverrideResult | EmulationSetTimezoneOverrideResult | EmulationSetTouchOverrideResult | EmulationSetUserAgentOverrideResult;
|
|
6
|
+
export interface EmulationSetForcedColorsModeThemeOverride {
|
|
7
|
+
method: "emulation.setForcedColorsModeThemeOverride";
|
|
8
|
+
params: EmulationSetForcedColorsModeThemeOverrideParameters;
|
|
9
|
+
}
|
|
10
|
+
export interface EmulationSetForcedColorsModeThemeOverrideParameters {
|
|
11
|
+
theme: EmulationForcedColorsModeTheme | null;
|
|
12
|
+
contexts?: BrowsingContextBrowsingContext[];
|
|
13
|
+
userContexts?: BrowserUserContext[];
|
|
14
|
+
}
|
|
15
|
+
export type EmulationForcedColorsModeTheme = "light" | "dark";
|
|
16
|
+
export type EmulationSetForcedColorsModeThemeOverrideResult = EmptyResult;
|
|
17
|
+
export interface EmulationSetGeolocationOverride {
|
|
18
|
+
method: "emulation.setGeolocationOverride";
|
|
19
|
+
params: EmulationSetGeolocationOverrideParameters;
|
|
20
|
+
}
|
|
21
|
+
export type EmulationSetGeolocationOverrideParameters = ({
|
|
22
|
+
coordinates: EmulationGeolocationCoordinates | null;
|
|
23
|
+
} | {
|
|
24
|
+
error: EmulationGeolocationPositionError;
|
|
25
|
+
}) & {
|
|
26
|
+
contexts?: BrowsingContextBrowsingContext[];
|
|
27
|
+
userContexts?: BrowserUserContext[];
|
|
28
|
+
};
|
|
29
|
+
export interface EmulationGeolocationCoordinates {
|
|
30
|
+
latitude: number;
|
|
31
|
+
longitude: number;
|
|
32
|
+
/**
|
|
33
|
+
* @default 1
|
|
34
|
+
*/
|
|
35
|
+
accuracy?: number;
|
|
36
|
+
/**
|
|
37
|
+
* @default null
|
|
38
|
+
*/
|
|
39
|
+
altitude?: number | null;
|
|
40
|
+
/**
|
|
41
|
+
* @default null
|
|
42
|
+
*/
|
|
43
|
+
altitudeAccuracy?: number | null;
|
|
44
|
+
/**
|
|
45
|
+
* @default null
|
|
46
|
+
*/
|
|
47
|
+
heading?: number | null;
|
|
48
|
+
/**
|
|
49
|
+
* @default null
|
|
50
|
+
*/
|
|
51
|
+
speed?: number | null;
|
|
52
|
+
}
|
|
53
|
+
export interface EmulationGeolocationPositionError {
|
|
54
|
+
type: "positionUnavailable";
|
|
55
|
+
}
|
|
56
|
+
export type EmulationSetGeolocationOverrideResult = EmptyResult;
|
|
57
|
+
export interface EmulationSetLocaleOverride {
|
|
58
|
+
method: "emulation.setLocaleOverride";
|
|
59
|
+
params: EmulationSetLocaleOverrideParameters;
|
|
60
|
+
}
|
|
61
|
+
export interface EmulationSetLocaleOverrideParameters {
|
|
62
|
+
locale: string | null;
|
|
63
|
+
contexts?: BrowsingContextBrowsingContext[];
|
|
64
|
+
userContexts?: BrowserUserContext[];
|
|
65
|
+
}
|
|
66
|
+
export type EmulationSetLocaleOverrideResult = EmptyResult;
|
|
67
|
+
export interface EmulationSetNetworkConditions {
|
|
68
|
+
method: "emulation.setNetworkConditions";
|
|
69
|
+
params: EmulationSetNetworkConditionsParameters;
|
|
70
|
+
}
|
|
71
|
+
export interface EmulationSetNetworkConditionsParameters {
|
|
72
|
+
networkConditions: EmulationNetworkConditions | null;
|
|
73
|
+
contexts?: BrowsingContextBrowsingContext[];
|
|
74
|
+
userContexts?: BrowserUserContext[];
|
|
75
|
+
}
|
|
76
|
+
export type EmulationNetworkConditions = EmulationNetworkConditionsOffline;
|
|
77
|
+
export interface EmulationNetworkConditionsOffline {
|
|
78
|
+
type: "offline";
|
|
79
|
+
}
|
|
80
|
+
export type EmulationSetNetworkConditionsResult = EmptyResult;
|
|
81
|
+
export interface EmulationSetScreenSettingsOverride {
|
|
82
|
+
method: "emulation.setScreenSettingsOverride";
|
|
83
|
+
params: EmulationSetScreenSettingsOverrideParameters;
|
|
84
|
+
}
|
|
85
|
+
export interface EmulationScreenArea {
|
|
86
|
+
width: JsUint;
|
|
87
|
+
height: JsUint;
|
|
88
|
+
}
|
|
89
|
+
export interface EmulationSetScreenSettingsOverrideParameters {
|
|
90
|
+
screenArea: EmulationScreenArea | null;
|
|
91
|
+
contexts?: BrowsingContextBrowsingContext[];
|
|
92
|
+
userContexts?: BrowserUserContext[];
|
|
93
|
+
}
|
|
94
|
+
export type EmulationSetScreenSettingsOverrideResult = EmptyResult;
|
|
95
|
+
export interface EmulationSetScreenOrientationOverride {
|
|
96
|
+
method: "emulation.setScreenOrientationOverride";
|
|
97
|
+
params: EmulationSetScreenOrientationOverrideParameters;
|
|
98
|
+
}
|
|
99
|
+
export type EmulationScreenOrientationNatural = "portrait" | "landscape";
|
|
100
|
+
export type EmulationScreenOrientationType = "portrait-primary" | "portrait-secondary" | "landscape-primary" | "landscape-secondary";
|
|
101
|
+
export interface EmulationScreenOrientation {
|
|
102
|
+
natural: EmulationScreenOrientationNatural;
|
|
103
|
+
type: EmulationScreenOrientationType;
|
|
104
|
+
}
|
|
105
|
+
export interface EmulationSetScreenOrientationOverrideParameters {
|
|
106
|
+
screenOrientation: EmulationScreenOrientation | null;
|
|
107
|
+
contexts?: BrowsingContextBrowsingContext[];
|
|
108
|
+
userContexts?: BrowserUserContext[];
|
|
109
|
+
}
|
|
110
|
+
export type EmulationSetScreenOrientationOverrideResult = EmptyResult;
|
|
111
|
+
export interface EmulationSetUserAgentOverride {
|
|
112
|
+
method: "emulation.setUserAgentOverride";
|
|
113
|
+
params: EmulationSetUserAgentOverrideParameters;
|
|
114
|
+
}
|
|
115
|
+
export interface EmulationSetUserAgentOverrideParameters {
|
|
116
|
+
userAgent: string | null;
|
|
117
|
+
contexts?: BrowsingContextBrowsingContext[];
|
|
118
|
+
userContexts?: BrowserUserContext[];
|
|
119
|
+
}
|
|
120
|
+
export type EmulationSetUserAgentOverrideResult = EmptyResult;
|
|
121
|
+
export interface EmulationSetScriptingEnabled {
|
|
122
|
+
method: "emulation.setScriptingEnabled";
|
|
123
|
+
params: EmulationSetScriptingEnabledParameters;
|
|
124
|
+
}
|
|
125
|
+
export interface EmulationSetScriptingEnabledParameters {
|
|
126
|
+
enabled: false | null;
|
|
127
|
+
contexts?: BrowsingContextBrowsingContext[];
|
|
128
|
+
userContexts?: BrowserUserContext[];
|
|
129
|
+
}
|
|
130
|
+
export type EmulationSetScriptingEnabledResult = EmptyResult;
|
|
131
|
+
export interface EmulationSetScrollbarTypeOverride {
|
|
132
|
+
method: "emulation.setScrollbarTypeOverride";
|
|
133
|
+
params: EmulationSetScrollbarTypeOverrideParameters;
|
|
134
|
+
}
|
|
135
|
+
export interface EmulationSetScrollbarTypeOverrideParameters {
|
|
136
|
+
scrollbarType: "classic" | "overlay" | null;
|
|
137
|
+
contexts?: BrowsingContextBrowsingContext[];
|
|
138
|
+
userContexts?: BrowserUserContext[];
|
|
139
|
+
}
|
|
140
|
+
export type EmulationSetScrollbarTypeOverrideResult = EmptyResult;
|
|
141
|
+
export interface EmulationSetTimezoneOverride {
|
|
142
|
+
method: "emulation.setTimezoneOverride";
|
|
143
|
+
params: EmulationSetTimezoneOverrideParameters;
|
|
144
|
+
}
|
|
145
|
+
export interface EmulationSetTimezoneOverrideParameters {
|
|
146
|
+
timezone: string | null;
|
|
147
|
+
contexts?: BrowsingContextBrowsingContext[];
|
|
148
|
+
userContexts?: BrowserUserContext[];
|
|
149
|
+
}
|
|
150
|
+
export type EmulationSetTimezoneOverrideResult = EmptyResult;
|
|
151
|
+
export interface EmulationSetTouchOverride {
|
|
152
|
+
method: "emulation.setTouchOverride";
|
|
153
|
+
params: EmulationSetTouchOverrideParameters;
|
|
154
|
+
}
|
|
155
|
+
export interface EmulationSetTouchOverrideParameters {
|
|
156
|
+
maxTouchPoints: JsUint | null;
|
|
157
|
+
contexts?: BrowsingContextBrowsingContext[];
|
|
158
|
+
userContexts?: BrowserUserContext[];
|
|
159
|
+
}
|
|
160
|
+
export type EmulationSetTouchOverrideResult = EmptyResult;
|
|
161
|
+
export declare class Emulation {
|
|
162
|
+
private readonly bidi;
|
|
163
|
+
private constructor();
|
|
164
|
+
static create(driver: unknown): Promise<Emulation>;
|
|
165
|
+
setForcedColorsModeThemeOverride(params: EmulationSetForcedColorsModeThemeOverrideParameters): Promise<void>;
|
|
166
|
+
setGeolocationOverride(params: EmulationSetGeolocationOverrideParameters): Promise<void>;
|
|
167
|
+
setLocaleOverride(params: EmulationSetLocaleOverrideParameters): Promise<void>;
|
|
168
|
+
setNetworkConditions(params: EmulationSetNetworkConditionsParameters): Promise<void>;
|
|
169
|
+
setScreenOrientationOverride(params: EmulationSetScreenOrientationOverrideParameters): Promise<void>;
|
|
170
|
+
setScreenSettingsOverride(params: EmulationSetScreenSettingsOverrideParameters): Promise<void>;
|
|
171
|
+
setScriptingEnabled(params: EmulationSetScriptingEnabledParameters): Promise<void>;
|
|
172
|
+
setScrollbarTypeOverride(params: EmulationSetScrollbarTypeOverrideParameters): Promise<void>;
|
|
173
|
+
setTimezoneOverride(params: EmulationSetTimezoneOverrideParameters): Promise<void>;
|
|
174
|
+
setTouchOverride(params: EmulationSetTouchOverrideParameters): Promise<void>;
|
|
175
|
+
setUserAgentOverride(params: EmulationSetUserAgentOverrideParameters): Promise<void>;
|
|
176
|
+
}
|
|
@@ -0,0 +1,133 @@
|
|
|
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.Emulation = void 0;
|
|
20
|
+
// --- Implementation ---
|
|
21
|
+
class Emulation {
|
|
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 Emulation(bidi);
|
|
32
|
+
}
|
|
33
|
+
async setForcedColorsModeThemeOverride(params) {
|
|
34
|
+
const response = await this.bidi.send({
|
|
35
|
+
method: 'emulation.setForcedColorsModeThemeOverride',
|
|
36
|
+
params: params,
|
|
37
|
+
});
|
|
38
|
+
if (response['type'] === 'error') {
|
|
39
|
+
throw new Error(`${response['error']}: ${response['message']}`);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
async setGeolocationOverride(params) {
|
|
43
|
+
const response = await this.bidi.send({
|
|
44
|
+
method: 'emulation.setGeolocationOverride',
|
|
45
|
+
params: params,
|
|
46
|
+
});
|
|
47
|
+
if (response['type'] === 'error') {
|
|
48
|
+
throw new Error(`${response['error']}: ${response['message']}`);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
async setLocaleOverride(params) {
|
|
52
|
+
const response = await this.bidi.send({
|
|
53
|
+
method: 'emulation.setLocaleOverride',
|
|
54
|
+
params: params,
|
|
55
|
+
});
|
|
56
|
+
if (response['type'] === 'error') {
|
|
57
|
+
throw new Error(`${response['error']}: ${response['message']}`);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
async setNetworkConditions(params) {
|
|
61
|
+
const response = await this.bidi.send({
|
|
62
|
+
method: 'emulation.setNetworkConditions',
|
|
63
|
+
params: params,
|
|
64
|
+
});
|
|
65
|
+
if (response['type'] === 'error') {
|
|
66
|
+
throw new Error(`${response['error']}: ${response['message']}`);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
async setScreenOrientationOverride(params) {
|
|
70
|
+
const response = await this.bidi.send({
|
|
71
|
+
method: 'emulation.setScreenOrientationOverride',
|
|
72
|
+
params: params,
|
|
73
|
+
});
|
|
74
|
+
if (response['type'] === 'error') {
|
|
75
|
+
throw new Error(`${response['error']}: ${response['message']}`);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
async setScreenSettingsOverride(params) {
|
|
79
|
+
const response = await this.bidi.send({
|
|
80
|
+
method: 'emulation.setScreenSettingsOverride',
|
|
81
|
+
params: params,
|
|
82
|
+
});
|
|
83
|
+
if (response['type'] === 'error') {
|
|
84
|
+
throw new Error(`${response['error']}: ${response['message']}`);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
async setScriptingEnabled(params) {
|
|
88
|
+
const response = await this.bidi.send({
|
|
89
|
+
method: 'emulation.setScriptingEnabled',
|
|
90
|
+
params: params,
|
|
91
|
+
});
|
|
92
|
+
if (response['type'] === 'error') {
|
|
93
|
+
throw new Error(`${response['error']}: ${response['message']}`);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
async setScrollbarTypeOverride(params) {
|
|
97
|
+
const response = await this.bidi.send({
|
|
98
|
+
method: 'emulation.setScrollbarTypeOverride',
|
|
99
|
+
params: params,
|
|
100
|
+
});
|
|
101
|
+
if (response['type'] === 'error') {
|
|
102
|
+
throw new Error(`${response['error']}: ${response['message']}`);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
async setTimezoneOverride(params) {
|
|
106
|
+
const response = await this.bidi.send({
|
|
107
|
+
method: 'emulation.setTimezoneOverride',
|
|
108
|
+
params: params,
|
|
109
|
+
});
|
|
110
|
+
if (response['type'] === 'error') {
|
|
111
|
+
throw new Error(`${response['error']}: ${response['message']}`);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
async setTouchOverride(params) {
|
|
115
|
+
const response = await this.bidi.send({
|
|
116
|
+
method: 'emulation.setTouchOverride',
|
|
117
|
+
params: params,
|
|
118
|
+
});
|
|
119
|
+
if (response['type'] === 'error') {
|
|
120
|
+
throw new Error(`${response['error']}: ${response['message']}`);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
async setUserAgentOverride(params) {
|
|
124
|
+
const response = await this.bidi.send({
|
|
125
|
+
method: 'emulation.setUserAgentOverride',
|
|
126
|
+
params: params,
|
|
127
|
+
});
|
|
128
|
+
if (response['type'] === 'error') {
|
|
129
|
+
throw new Error(`${response['error']}: ${response['message']}`);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
exports.Emulation = Emulation;
|