selenium-webdriver 4.44.0 → 4.45.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 +13 -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 +394 -0
- package/bidi/generated/browsing_context.js +260 -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/webdriver.js +2 -2
- package/package.json +16 -14
|
@@ -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;
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import type { BrowserUserContext } from './browser.js';
|
|
2
|
+
import type { BrowsingContextBrowsingContext } from './browsing_context.js';
|
|
3
|
+
import type { EmptyResult, JsInt, JsUint } from './common.js';
|
|
4
|
+
import type { ScriptSharedReference } from './script.js';
|
|
5
|
+
export type InputCommand = InputPerformActions | InputReleaseActions | InputSetFiles;
|
|
6
|
+
export type InputResult = InputPerformActionsResult | InputReleaseActionsResult | InputSetFilesResult;
|
|
7
|
+
export type InputEvent = InputFileDialogOpened;
|
|
8
|
+
export interface InputElementOrigin {
|
|
9
|
+
type: "element";
|
|
10
|
+
element: ScriptSharedReference;
|
|
11
|
+
}
|
|
12
|
+
export interface InputPerformActions {
|
|
13
|
+
method: "input.performActions";
|
|
14
|
+
params: InputPerformActionsParameters;
|
|
15
|
+
}
|
|
16
|
+
export interface InputPerformActionsParameters {
|
|
17
|
+
context: BrowsingContextBrowsingContext;
|
|
18
|
+
actions: InputSourceActions[];
|
|
19
|
+
}
|
|
20
|
+
export type InputSourceActions = InputNoneSourceActions | InputKeySourceActions | InputPointerSourceActions | InputWheelSourceActions;
|
|
21
|
+
export interface InputNoneSourceActions {
|
|
22
|
+
type: "none";
|
|
23
|
+
id: string;
|
|
24
|
+
actions: InputNoneSourceAction[];
|
|
25
|
+
}
|
|
26
|
+
export type InputNoneSourceAction = InputPauseAction;
|
|
27
|
+
export interface InputKeySourceActions {
|
|
28
|
+
type: "key";
|
|
29
|
+
id: string;
|
|
30
|
+
actions: InputKeySourceAction[];
|
|
31
|
+
}
|
|
32
|
+
export type InputKeySourceAction = InputPauseAction | InputKeyDownAction | InputKeyUpAction;
|
|
33
|
+
export interface InputPointerSourceActions {
|
|
34
|
+
type: "pointer";
|
|
35
|
+
id: string;
|
|
36
|
+
parameters?: InputPointerParameters;
|
|
37
|
+
actions: InputPointerSourceAction[];
|
|
38
|
+
}
|
|
39
|
+
export type InputPointerType = "mouse" | "pen" | "touch";
|
|
40
|
+
export interface InputPointerParameters {
|
|
41
|
+
/**
|
|
42
|
+
* @default 'mouse'
|
|
43
|
+
*/
|
|
44
|
+
pointerType?: InputPointerType;
|
|
45
|
+
}
|
|
46
|
+
export type InputPointerSourceAction = InputPauseAction | InputPointerDownAction | InputPointerUpAction | InputPointerMoveAction;
|
|
47
|
+
export interface InputWheelSourceActions {
|
|
48
|
+
type: "wheel";
|
|
49
|
+
id: string;
|
|
50
|
+
actions: InputWheelSourceAction[];
|
|
51
|
+
}
|
|
52
|
+
export type InputWheelSourceAction = InputPauseAction | InputWheelScrollAction;
|
|
53
|
+
export interface InputPauseAction {
|
|
54
|
+
type: "pause";
|
|
55
|
+
duration?: JsUint;
|
|
56
|
+
}
|
|
57
|
+
export interface InputKeyDownAction {
|
|
58
|
+
type: "keyDown";
|
|
59
|
+
value: string;
|
|
60
|
+
}
|
|
61
|
+
export interface InputKeyUpAction {
|
|
62
|
+
type: "keyUp";
|
|
63
|
+
value: string;
|
|
64
|
+
}
|
|
65
|
+
export interface InputPointerUpAction {
|
|
66
|
+
type: "pointerUp";
|
|
67
|
+
button: JsUint;
|
|
68
|
+
}
|
|
69
|
+
export type InputPointerDownAction = InputPointerCommonProperties & {
|
|
70
|
+
type: "pointerDown";
|
|
71
|
+
button: JsUint;
|
|
72
|
+
};
|
|
73
|
+
export type InputPointerMoveAction = InputPointerCommonProperties & {
|
|
74
|
+
type: "pointerMove";
|
|
75
|
+
x: number;
|
|
76
|
+
y: number;
|
|
77
|
+
duration?: JsUint;
|
|
78
|
+
origin?: InputOrigin;
|
|
79
|
+
};
|
|
80
|
+
export interface InputWheelScrollAction {
|
|
81
|
+
type: "scroll";
|
|
82
|
+
x: JsInt;
|
|
83
|
+
y: JsInt;
|
|
84
|
+
deltaX: JsInt;
|
|
85
|
+
deltaY: JsInt;
|
|
86
|
+
duration?: JsUint;
|
|
87
|
+
/**
|
|
88
|
+
* @default 'viewport'
|
|
89
|
+
*/
|
|
90
|
+
origin?: InputOrigin;
|
|
91
|
+
}
|
|
92
|
+
export interface InputPointerCommonProperties {
|
|
93
|
+
width?: JsUint;
|
|
94
|
+
height?: JsUint;
|
|
95
|
+
pressure?: number;
|
|
96
|
+
tangentialPressure?: number;
|
|
97
|
+
/**
|
|
98
|
+
* 0 .. Math.PI / 2
|
|
99
|
+
*/
|
|
100
|
+
twist?: number;
|
|
101
|
+
/**
|
|
102
|
+
* 0 .. 2 * Math.PI
|
|
103
|
+
*/
|
|
104
|
+
altitudeAngle?: number;
|
|
105
|
+
azimuthAngle?: number;
|
|
106
|
+
}
|
|
107
|
+
export type InputOrigin = "viewport" | "pointer" | InputElementOrigin;
|
|
108
|
+
export type InputPerformActionsResult = EmptyResult;
|
|
109
|
+
export interface InputReleaseActions {
|
|
110
|
+
method: "input.releaseActions";
|
|
111
|
+
params: InputReleaseActionsParameters;
|
|
112
|
+
}
|
|
113
|
+
export interface InputReleaseActionsParameters {
|
|
114
|
+
context: BrowsingContextBrowsingContext;
|
|
115
|
+
}
|
|
116
|
+
export type InputReleaseActionsResult = EmptyResult;
|
|
117
|
+
export interface InputSetFiles {
|
|
118
|
+
method: "input.setFiles";
|
|
119
|
+
params: InputSetFilesParameters;
|
|
120
|
+
}
|
|
121
|
+
export interface InputSetFilesParameters {
|
|
122
|
+
context: BrowsingContextBrowsingContext;
|
|
123
|
+
element: ScriptSharedReference;
|
|
124
|
+
files: string[];
|
|
125
|
+
}
|
|
126
|
+
export type InputSetFilesResult = EmptyResult;
|
|
127
|
+
export interface InputFileDialogOpened {
|
|
128
|
+
method: "input.fileDialogOpened";
|
|
129
|
+
params: InputFileDialogInfo;
|
|
130
|
+
}
|
|
131
|
+
export interface InputFileDialogInfo {
|
|
132
|
+
context: BrowsingContextBrowsingContext;
|
|
133
|
+
userContext?: BrowserUserContext;
|
|
134
|
+
element?: ScriptSharedReference;
|
|
135
|
+
multiple: boolean;
|
|
136
|
+
}
|
|
137
|
+
/** @deprecated Use {@link Input.create} instead — will be removed in a future major version. */
|
|
138
|
+
export declare function getInputInstance(driver: unknown): Promise<Input>;
|
|
139
|
+
export declare class Input {
|
|
140
|
+
private readonly bidi;
|
|
141
|
+
private constructor();
|
|
142
|
+
static create(driver: unknown): Promise<Input>;
|
|
143
|
+
performActions(params: InputPerformActionsParameters): Promise<void>;
|
|
144
|
+
releaseActions(params: InputReleaseActionsParameters): Promise<void>;
|
|
145
|
+
setFiles(params: InputSetFilesParameters): Promise<void>;
|
|
146
|
+
onFileDialogOpened(callback: (params: InputFileDialogInfo) => void): Promise<void>;
|
|
147
|
+
/** @deprecated Use {@link performActions} instead — will be removed in a future major version. */
|
|
148
|
+
perform(browsingContextId: string, actions: InputSourceActions[]): Promise<void>;
|
|
149
|
+
/** @deprecated Use {@link releaseActions} instead — will be removed in a future major version. */
|
|
150
|
+
release(browsingContextId: string): Promise<void>;
|
|
151
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
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.Input = exports.getInputInstance = void 0;
|
|
20
|
+
// --- Additional Types ---
|
|
21
|
+
/** @deprecated Use {@link Input.create} instead — will be removed in a future major version. */
|
|
22
|
+
async function getInputInstance(driver) {
|
|
23
|
+
return Input.create(driver);
|
|
24
|
+
}
|
|
25
|
+
exports.getInputInstance = getInputInstance;
|
|
26
|
+
// --- Implementation ---
|
|
27
|
+
class Input {
|
|
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 Input(bidi);
|
|
38
|
+
}
|
|
39
|
+
async performActions(params) {
|
|
40
|
+
const response = await this.bidi.send({
|
|
41
|
+
method: 'input.performActions',
|
|
42
|
+
params: params,
|
|
43
|
+
});
|
|
44
|
+
if (response['type'] === 'error') {
|
|
45
|
+
throw new Error(`${response['error']}: ${response['message']}`);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
async releaseActions(params) {
|
|
49
|
+
const response = await this.bidi.send({
|
|
50
|
+
method: 'input.releaseActions',
|
|
51
|
+
params: params,
|
|
52
|
+
});
|
|
53
|
+
if (response['type'] === 'error') {
|
|
54
|
+
throw new Error(`${response['error']}: ${response['message']}`);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
async setFiles(params) {
|
|
58
|
+
const response = await this.bidi.send({
|
|
59
|
+
method: 'input.setFiles',
|
|
60
|
+
params: params,
|
|
61
|
+
});
|
|
62
|
+
if (response['type'] === 'error') {
|
|
63
|
+
throw new Error(`${response['error']}: ${response['message']}`);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
async onFileDialogOpened(callback) {
|
|
67
|
+
await this.bidi.subscribe('input.fileDialogOpened');
|
|
68
|
+
this.bidi.on('input.fileDialogOpened', (params) => {
|
|
69
|
+
callback(params);
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
/** @deprecated Use {@link performActions} instead — will be removed in a future major version. */
|
|
73
|
+
async perform(browsingContextId, actions) {
|
|
74
|
+
await this.performActions({ context: browsingContextId, actions });
|
|
75
|
+
}
|
|
76
|
+
/** @deprecated Use {@link releaseActions} instead — will be removed in a future major version. */
|
|
77
|
+
async release(browsingContextId) {
|
|
78
|
+
await this.releaseActions({ context: browsingContextId });
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
exports.Input = Input;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { JsUint } from './common.js';
|
|
2
|
+
import type { ScriptRemoteValue, ScriptSource, ScriptStackTrace } from './script.js';
|
|
3
|
+
export type LogEvent = LogEntryAdded;
|
|
4
|
+
export type LogLevel = "debug" | "info" | "warn" | "error";
|
|
5
|
+
export type LogEntry = LogGenericLogEntry | LogConsoleLogEntry | LogJavascriptLogEntry;
|
|
6
|
+
export interface LogBaseLogEntry {
|
|
7
|
+
level: LogLevel;
|
|
8
|
+
source: ScriptSource;
|
|
9
|
+
text: string | null;
|
|
10
|
+
timestamp: JsUint;
|
|
11
|
+
stackTrace?: ScriptStackTrace;
|
|
12
|
+
}
|
|
13
|
+
export type LogGenericLogEntry = LogBaseLogEntry & {
|
|
14
|
+
type: string;
|
|
15
|
+
};
|
|
16
|
+
export type LogConsoleLogEntry = LogBaseLogEntry & {
|
|
17
|
+
type: "console";
|
|
18
|
+
method: string;
|
|
19
|
+
args: ScriptRemoteValue[];
|
|
20
|
+
};
|
|
21
|
+
export type LogJavascriptLogEntry = LogBaseLogEntry & {
|
|
22
|
+
type: "javascript";
|
|
23
|
+
};
|
|
24
|
+
export interface LogEntryAdded {
|
|
25
|
+
method: "log.entryAdded";
|
|
26
|
+
params: LogEntry;
|
|
27
|
+
}
|
|
28
|
+
/** @deprecated Use {@link Log.create} instead — will be removed in a future major version. */
|
|
29
|
+
export declare function getLogInspectorInstance(driver: unknown): Promise<Log>;
|
|
30
|
+
export declare class Log {
|
|
31
|
+
private readonly bidi;
|
|
32
|
+
private constructor();
|
|
33
|
+
static create(driver: unknown): Promise<Log>;
|
|
34
|
+
onEntryAdded(callback: (params: LogEntry) => void): Promise<void>;
|
|
35
|
+
onConsoleEntry(callback: (params: LogEntry) => void): Promise<void>;
|
|
36
|
+
onJavascriptLog(callback: (params: LogEntry) => void): Promise<void>;
|
|
37
|
+
onJavascriptException(callback: (params: LogEntry) => void): Promise<void>;
|
|
38
|
+
onLog(callback: (params: LogEntry) => void): Promise<void>;
|
|
39
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
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.Log = exports.getLogInspectorInstance = void 0;
|
|
20
|
+
// --- Additional Types ---
|
|
21
|
+
/** @deprecated Use {@link Log.create} instead — will be removed in a future major version. */
|
|
22
|
+
async function getLogInspectorInstance(driver) {
|
|
23
|
+
return Log.create(driver);
|
|
24
|
+
}
|
|
25
|
+
exports.getLogInspectorInstance = getLogInspectorInstance;
|
|
26
|
+
// --- Implementation ---
|
|
27
|
+
class Log {
|
|
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 Log(bidi);
|
|
38
|
+
}
|
|
39
|
+
async onEntryAdded(callback) {
|
|
40
|
+
await this.bidi.subscribe('log.entryAdded');
|
|
41
|
+
this.bidi.on('log.entryAdded', (params) => {
|
|
42
|
+
callback(params);
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
async onConsoleEntry(callback) {
|
|
46
|
+
await this.onEntryAdded((entry) => {
|
|
47
|
+
if (entry.type === 'console')
|
|
48
|
+
callback(entry);
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
async onJavascriptLog(callback) {
|
|
52
|
+
await this.onEntryAdded((entry) => {
|
|
53
|
+
if (entry.type === 'javascript')
|
|
54
|
+
callback(entry);
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
async onJavascriptException(callback) {
|
|
58
|
+
await this.onEntryAdded((entry) => {
|
|
59
|
+
if (entry.type === 'javascript' && entry.level === 'error')
|
|
60
|
+
callback(entry);
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
async onLog(callback) {
|
|
64
|
+
await this.onEntryAdded(callback);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
exports.Log = Log;
|