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
package/CHANGES.md
CHANGED
|
@@ -1,3 +1,23 @@
|
|
|
1
|
+
## 4.46.0
|
|
2
|
+
|
|
3
|
+
- Support CDP versions: v148, v149, v150
|
|
4
|
+
- Add binding-neutral BiDi schema with cddl2ts-gated fidelity (#17700)
|
|
5
|
+
- Update cddl to 0.21.0 to fix quoted reserved-word parsing in BiDi codegen (#17752)
|
|
6
|
+
- Add guidance for testing conventions in each language (#16734)
|
|
7
|
+
|
|
8
|
+
## 4.45.0
|
|
9
|
+
|
|
10
|
+
- Support CDP versions: v147, v148, v149
|
|
11
|
+
- update vulnerable dependency with a range (#17466)
|
|
12
|
+
- update dev dependencies (#17479)
|
|
13
|
+
- update eslint to v10 with fixes (#17482)
|
|
14
|
+
- Use the typescript atom for get attribute (#17526)
|
|
15
|
+
- Move JS bindings to use typescript atoms for isDisplayed and Find-Element (#17547)
|
|
16
|
+
- trim agent formatting guidance (#17617)
|
|
17
|
+
- [build] Automated Browser Version Update (#17609)
|
|
18
|
+
- Add Javascript/Typescript CDDL code generator for WebDriver BiDi (#17574)
|
|
19
|
+
- Expose BiDi CDDL ast and model as shared artifacts (#17657)
|
|
20
|
+
|
|
1
21
|
## 4.44.0
|
|
2
22
|
|
|
3
23
|
- Support CDP versions: v146, v147, v148
|
|
@@ -124,7 +124,7 @@ class BrowsingContextInspector {
|
|
|
124
124
|
this.ws.on('message', (event) => {
|
|
125
125
|
const { params } = JSON.parse(Buffer.from(event.toString()))
|
|
126
126
|
if (params) {
|
|
127
|
-
let response
|
|
127
|
+
let response
|
|
128
128
|
if ('navigation' in params) {
|
|
129
129
|
response = new NavigationInfo(params.context, params.navigation, params.timestamp, params.url)
|
|
130
130
|
} else if ('accepted' in params) {
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
export type BluetoothBluetoothUuid = string;
|
|
2
|
+
export interface BluetoothBluetoothManufacturerData {
|
|
3
|
+
key: number;
|
|
4
|
+
data: string;
|
|
5
|
+
}
|
|
6
|
+
export interface BluetoothCharacteristicProperties {
|
|
7
|
+
broadcast?: boolean;
|
|
8
|
+
read?: boolean;
|
|
9
|
+
writeWithoutResponse?: boolean;
|
|
10
|
+
write?: boolean;
|
|
11
|
+
notify?: boolean;
|
|
12
|
+
indicate?: boolean;
|
|
13
|
+
authenticatedSignedWrites?: boolean;
|
|
14
|
+
extendedProperties?: boolean;
|
|
15
|
+
}
|
|
16
|
+
export type BluetoothRequestDevice = string;
|
|
17
|
+
export interface BluetoothRequestDeviceInfo {
|
|
18
|
+
id: BluetoothRequestDevice;
|
|
19
|
+
name: string | null;
|
|
20
|
+
}
|
|
21
|
+
export type BluetoothRequestDevicePrompt = string;
|
|
22
|
+
export interface BluetoothScanRecord {
|
|
23
|
+
name?: string;
|
|
24
|
+
uuids?: BluetoothBluetoothUuid[];
|
|
25
|
+
appearance?: Number;
|
|
26
|
+
manufacturerData?: BluetoothBluetoothManufacturerData[];
|
|
27
|
+
}
|
|
28
|
+
export type BluetoothCommand = BluetoothHandleRequestDevicePrompt | BluetoothSimulateAdapter | BluetoothDisableSimulation | BluetoothSimulatePreconnectedPeripheral | BluetoothSimulateAdvertisement | BluetoothSimulateGattConnectionResponse | BluetoothSimulateGattDisconnection | BluetoothSimulateService | BluetoothSimulateCharacteristic | BluetoothSimulateCharacteristicResponse | BluetoothSimulateDescriptor | BluetoothSimulateDescriptorResponse;
|
|
29
|
+
export interface BluetoothHandleRequestDevicePrompt {
|
|
30
|
+
method: "bluetooth.handleRequestDevicePrompt";
|
|
31
|
+
params: BluetoothHandleRequestDevicePromptParameters;
|
|
32
|
+
}
|
|
33
|
+
export type BluetoothHandleRequestDevicePromptParameters = (BluetoothHandleRequestDevicePromptAcceptParameters | BluetoothHandleRequestDevicePromptCancelParameters) & {
|
|
34
|
+
context: string;
|
|
35
|
+
prompt: BluetoothRequestDevicePrompt;
|
|
36
|
+
};
|
|
37
|
+
export interface BluetoothHandleRequestDevicePromptAcceptParameters {
|
|
38
|
+
accept: true;
|
|
39
|
+
device: BluetoothRequestDevice;
|
|
40
|
+
}
|
|
41
|
+
export interface BluetoothHandleRequestDevicePromptCancelParameters {
|
|
42
|
+
accept: false;
|
|
43
|
+
}
|
|
44
|
+
export interface BluetoothSimulateAdapter {
|
|
45
|
+
method: "bluetooth.simulateAdapter";
|
|
46
|
+
params: BluetoothSimulateAdapterParameters;
|
|
47
|
+
}
|
|
48
|
+
export interface BluetoothSimulateAdapterParameters {
|
|
49
|
+
context: string;
|
|
50
|
+
leSupported?: boolean;
|
|
51
|
+
state: "absent" | "powered-off" | "powered-on";
|
|
52
|
+
}
|
|
53
|
+
export interface BluetoothDisableSimulation {
|
|
54
|
+
method: "bluetooth.disableSimulation";
|
|
55
|
+
params: BluetoothDisableSimulationParameters;
|
|
56
|
+
}
|
|
57
|
+
export interface BluetoothDisableSimulationParameters {
|
|
58
|
+
context: string;
|
|
59
|
+
}
|
|
60
|
+
export interface BluetoothSimulatePreconnectedPeripheral {
|
|
61
|
+
method: "bluetooth.simulatePreconnectedPeripheral";
|
|
62
|
+
params: BluetoothSimulatePreconnectedPeripheralParameters;
|
|
63
|
+
}
|
|
64
|
+
export interface BluetoothSimulatePreconnectedPeripheralParameters {
|
|
65
|
+
context: string;
|
|
66
|
+
address: string;
|
|
67
|
+
name: string;
|
|
68
|
+
manufacturerData: BluetoothBluetoothManufacturerData[];
|
|
69
|
+
knownServiceUuids: BluetoothBluetoothUuid[];
|
|
70
|
+
}
|
|
71
|
+
export interface BluetoothSimulateAdvertisement {
|
|
72
|
+
method: "bluetooth.simulateAdvertisement";
|
|
73
|
+
params: BluetoothSimulateAdvertisementParameters;
|
|
74
|
+
}
|
|
75
|
+
export interface BluetoothSimulateAdvertisementParameters {
|
|
76
|
+
context: string;
|
|
77
|
+
scanEntry: BluetoothSimulateAdvertisementScanEntryParameters;
|
|
78
|
+
}
|
|
79
|
+
export interface BluetoothSimulateAdvertisementScanEntryParameters {
|
|
80
|
+
deviceAddress: string;
|
|
81
|
+
rssi: Number;
|
|
82
|
+
scanRecord: BluetoothScanRecord;
|
|
83
|
+
}
|
|
84
|
+
export interface BluetoothSimulateGattConnectionResponse {
|
|
85
|
+
method: "bluetooth.simulateGattConnectionResponse";
|
|
86
|
+
params: BluetoothSimulateGattConnectionResponseParameters;
|
|
87
|
+
}
|
|
88
|
+
export interface BluetoothSimulateGattConnectionResponseParameters {
|
|
89
|
+
context: string;
|
|
90
|
+
address: string;
|
|
91
|
+
code: number;
|
|
92
|
+
}
|
|
93
|
+
export interface BluetoothSimulateGattDisconnection {
|
|
94
|
+
method: "bluetooth.simulateGattDisconnection";
|
|
95
|
+
params: BluetoothSimulateGattDisconnectionParameters;
|
|
96
|
+
}
|
|
97
|
+
export interface BluetoothSimulateGattDisconnectionParameters {
|
|
98
|
+
context: string;
|
|
99
|
+
address: string;
|
|
100
|
+
}
|
|
101
|
+
export interface BluetoothSimulateService {
|
|
102
|
+
method: "bluetooth.simulateService";
|
|
103
|
+
params: BluetoothSimulateServiceParameters;
|
|
104
|
+
}
|
|
105
|
+
export interface BluetoothSimulateServiceParameters {
|
|
106
|
+
context: string;
|
|
107
|
+
address: string;
|
|
108
|
+
uuid: BluetoothBluetoothUuid;
|
|
109
|
+
type: "add" | "remove";
|
|
110
|
+
}
|
|
111
|
+
export interface BluetoothSimulateCharacteristic {
|
|
112
|
+
method: "bluetooth.simulateCharacteristic";
|
|
113
|
+
params: BluetoothSimulateCharacteristicParameters;
|
|
114
|
+
}
|
|
115
|
+
export interface BluetoothSimulateCharacteristicParameters {
|
|
116
|
+
context: string;
|
|
117
|
+
address: string;
|
|
118
|
+
serviceUuid: BluetoothBluetoothUuid;
|
|
119
|
+
characteristicUuid: BluetoothBluetoothUuid;
|
|
120
|
+
characteristicProperties?: BluetoothCharacteristicProperties;
|
|
121
|
+
type: "add" | "remove";
|
|
122
|
+
}
|
|
123
|
+
export interface BluetoothSimulateCharacteristicResponse {
|
|
124
|
+
method: "bluetooth.simulateCharacteristicResponse";
|
|
125
|
+
params: BluetoothSimulateCharacteristicResponseParameters;
|
|
126
|
+
}
|
|
127
|
+
export interface BluetoothSimulateCharacteristicResponseParameters {
|
|
128
|
+
context: string;
|
|
129
|
+
address: string;
|
|
130
|
+
serviceUuid: BluetoothBluetoothUuid;
|
|
131
|
+
characteristicUuid: BluetoothBluetoothUuid;
|
|
132
|
+
type: "read" | "write" | "subscribe-to-notifications" | "unsubscribe-from-notifications";
|
|
133
|
+
code: number;
|
|
134
|
+
data?: number[];
|
|
135
|
+
}
|
|
136
|
+
export interface BluetoothSimulateDescriptor {
|
|
137
|
+
method: "bluetooth.simulateDescriptor";
|
|
138
|
+
params: BluetoothSimulateDescriptorParameters;
|
|
139
|
+
}
|
|
140
|
+
export interface BluetoothSimulateDescriptorParameters {
|
|
141
|
+
context: string;
|
|
142
|
+
address: string;
|
|
143
|
+
serviceUuid: BluetoothBluetoothUuid;
|
|
144
|
+
characteristicUuid: BluetoothBluetoothUuid;
|
|
145
|
+
descriptorUuid: BluetoothBluetoothUuid;
|
|
146
|
+
type: "add" | "remove";
|
|
147
|
+
}
|
|
148
|
+
export interface BluetoothSimulateDescriptorResponse {
|
|
149
|
+
method: "bluetooth.simulateDescriptorResponse";
|
|
150
|
+
params: BluetoothSimulateDescriptorResponseParameters;
|
|
151
|
+
}
|
|
152
|
+
export interface BluetoothSimulateDescriptorResponseParameters {
|
|
153
|
+
context: string;
|
|
154
|
+
address: string;
|
|
155
|
+
serviceUuid: BluetoothBluetoothUuid;
|
|
156
|
+
characteristicUuid: BluetoothBluetoothUuid;
|
|
157
|
+
descriptorUuid: BluetoothBluetoothUuid;
|
|
158
|
+
type: "read" | "write";
|
|
159
|
+
code: number;
|
|
160
|
+
data?: number[];
|
|
161
|
+
}
|
|
162
|
+
export type BluetoothEvent = BluetoothRequestDevicePromptUpdated | BluetoothGattConnectionAttempted;
|
|
163
|
+
export interface BluetoothRequestDevicePromptUpdated {
|
|
164
|
+
method: "bluetooth.requestDevicePromptUpdated";
|
|
165
|
+
params: BluetoothRequestDevicePromptUpdatedParameters;
|
|
166
|
+
}
|
|
167
|
+
export interface BluetoothRequestDevicePromptUpdatedParameters {
|
|
168
|
+
context: string;
|
|
169
|
+
prompt: BluetoothRequestDevicePrompt;
|
|
170
|
+
devices: BluetoothRequestDeviceInfo[];
|
|
171
|
+
}
|
|
172
|
+
export interface BluetoothGattConnectionAttempted {
|
|
173
|
+
method: "bluetooth.gattConnectionAttempted";
|
|
174
|
+
params: BluetoothGattConnectionAttemptedParameters;
|
|
175
|
+
}
|
|
176
|
+
export interface BluetoothGattConnectionAttemptedParameters {
|
|
177
|
+
context: string;
|
|
178
|
+
address: string;
|
|
179
|
+
}
|
|
180
|
+
export interface BluetoothCharacteristicEventGenerated {
|
|
181
|
+
method: "bluetooth.characteristicEventGenerated";
|
|
182
|
+
params: BluetoothCharacteristicEventGeneratedParameters;
|
|
183
|
+
}
|
|
184
|
+
export interface BluetoothCharacteristicEventGeneratedParameters {
|
|
185
|
+
context: string;
|
|
186
|
+
address: string;
|
|
187
|
+
serviceUuid: BluetoothBluetoothUuid;
|
|
188
|
+
characteristicUuid: BluetoothBluetoothUuid;
|
|
189
|
+
type: "read" | "write-with-response" | "write-without-response" | "subscribe-to-notifications" | "unsubscribe-from-notifications";
|
|
190
|
+
data?: number[];
|
|
191
|
+
}
|
|
192
|
+
export interface BluetoothDescriptorEventGenerated {
|
|
193
|
+
method: "bluetooth.descriptorEventGenerated";
|
|
194
|
+
params: BluetoothDescriptorEventGeneratedParameters;
|
|
195
|
+
}
|
|
196
|
+
export interface BluetoothDescriptorEventGeneratedParameters {
|
|
197
|
+
context: string;
|
|
198
|
+
address: string;
|
|
199
|
+
serviceUuid: BluetoothBluetoothUuid;
|
|
200
|
+
characteristicUuid: BluetoothBluetoothUuid;
|
|
201
|
+
descriptorUuid: BluetoothBluetoothUuid;
|
|
202
|
+
type: "read" | "write";
|
|
203
|
+
data?: number[];
|
|
204
|
+
}
|
|
205
|
+
export declare class Bluetooth {
|
|
206
|
+
private readonly bidi;
|
|
207
|
+
private constructor();
|
|
208
|
+
static create(driver: unknown): Promise<Bluetooth>;
|
|
209
|
+
handleRequestDevicePrompt(params: BluetoothHandleRequestDevicePromptParameters): Promise<void>;
|
|
210
|
+
simulateAdapter(params: BluetoothSimulateAdapterParameters): Promise<void>;
|
|
211
|
+
disableSimulation(params: BluetoothDisableSimulationParameters): Promise<void>;
|
|
212
|
+
simulatePreconnectedPeripheral(params: BluetoothSimulatePreconnectedPeripheralParameters): Promise<void>;
|
|
213
|
+
simulateAdvertisement(params: BluetoothSimulateAdvertisementParameters): Promise<void>;
|
|
214
|
+
simulateGattConnectionResponse(params: BluetoothSimulateGattConnectionResponseParameters): Promise<void>;
|
|
215
|
+
simulateGattDisconnection(params: BluetoothSimulateGattDisconnectionParameters): Promise<void>;
|
|
216
|
+
simulateService(params: BluetoothSimulateServiceParameters): Promise<void>;
|
|
217
|
+
simulateCharacteristic(params: BluetoothSimulateCharacteristicParameters): Promise<void>;
|
|
218
|
+
simulateCharacteristicResponse(params: BluetoothSimulateCharacteristicResponseParameters): Promise<void>;
|
|
219
|
+
simulateDescriptor(params: BluetoothSimulateDescriptorParameters): Promise<void>;
|
|
220
|
+
simulateDescriptorResponse(params: BluetoothSimulateDescriptorResponseParameters): Promise<void>;
|
|
221
|
+
onRequestDevicePromptUpdated(callback: (params: BluetoothRequestDevicePromptUpdatedParameters) => void): Promise<void>;
|
|
222
|
+
onGattConnectionAttempted(callback: (params: BluetoothGattConnectionAttemptedParameters) => void): Promise<void>;
|
|
223
|
+
}
|
|
@@ -0,0 +1,154 @@
|
|
|
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.Bluetooth = void 0;
|
|
20
|
+
// --- Implementation ---
|
|
21
|
+
class Bluetooth {
|
|
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 Bluetooth(bidi);
|
|
32
|
+
}
|
|
33
|
+
async handleRequestDevicePrompt(params) {
|
|
34
|
+
const response = await this.bidi.send({
|
|
35
|
+
method: 'bluetooth.handleRequestDevicePrompt',
|
|
36
|
+
params: params,
|
|
37
|
+
});
|
|
38
|
+
if (response['type'] === 'error') {
|
|
39
|
+
throw new Error(`${response['error']}: ${response['message']}`);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
async simulateAdapter(params) {
|
|
43
|
+
const response = await this.bidi.send({
|
|
44
|
+
method: 'bluetooth.simulateAdapter',
|
|
45
|
+
params: params,
|
|
46
|
+
});
|
|
47
|
+
if (response['type'] === 'error') {
|
|
48
|
+
throw new Error(`${response['error']}: ${response['message']}`);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
async disableSimulation(params) {
|
|
52
|
+
const response = await this.bidi.send({
|
|
53
|
+
method: 'bluetooth.disableSimulation',
|
|
54
|
+
params: params,
|
|
55
|
+
});
|
|
56
|
+
if (response['type'] === 'error') {
|
|
57
|
+
throw new Error(`${response['error']}: ${response['message']}`);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
async simulatePreconnectedPeripheral(params) {
|
|
61
|
+
const response = await this.bidi.send({
|
|
62
|
+
method: 'bluetooth.simulatePreconnectedPeripheral',
|
|
63
|
+
params: params,
|
|
64
|
+
});
|
|
65
|
+
if (response['type'] === 'error') {
|
|
66
|
+
throw new Error(`${response['error']}: ${response['message']}`);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
async simulateAdvertisement(params) {
|
|
70
|
+
const response = await this.bidi.send({
|
|
71
|
+
method: 'bluetooth.simulateAdvertisement',
|
|
72
|
+
params: params,
|
|
73
|
+
});
|
|
74
|
+
if (response['type'] === 'error') {
|
|
75
|
+
throw new Error(`${response['error']}: ${response['message']}`);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
async simulateGattConnectionResponse(params) {
|
|
79
|
+
const response = await this.bidi.send({
|
|
80
|
+
method: 'bluetooth.simulateGattConnectionResponse',
|
|
81
|
+
params: params,
|
|
82
|
+
});
|
|
83
|
+
if (response['type'] === 'error') {
|
|
84
|
+
throw new Error(`${response['error']}: ${response['message']}`);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
async simulateGattDisconnection(params) {
|
|
88
|
+
const response = await this.bidi.send({
|
|
89
|
+
method: 'bluetooth.simulateGattDisconnection',
|
|
90
|
+
params: params,
|
|
91
|
+
});
|
|
92
|
+
if (response['type'] === 'error') {
|
|
93
|
+
throw new Error(`${response['error']}: ${response['message']}`);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
async simulateService(params) {
|
|
97
|
+
const response = await this.bidi.send({
|
|
98
|
+
method: 'bluetooth.simulateService',
|
|
99
|
+
params: params,
|
|
100
|
+
});
|
|
101
|
+
if (response['type'] === 'error') {
|
|
102
|
+
throw new Error(`${response['error']}: ${response['message']}`);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
async simulateCharacteristic(params) {
|
|
106
|
+
const response = await this.bidi.send({
|
|
107
|
+
method: 'bluetooth.simulateCharacteristic',
|
|
108
|
+
params: params,
|
|
109
|
+
});
|
|
110
|
+
if (response['type'] === 'error') {
|
|
111
|
+
throw new Error(`${response['error']}: ${response['message']}`);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
async simulateCharacteristicResponse(params) {
|
|
115
|
+
const response = await this.bidi.send({
|
|
116
|
+
method: 'bluetooth.simulateCharacteristicResponse',
|
|
117
|
+
params: params,
|
|
118
|
+
});
|
|
119
|
+
if (response['type'] === 'error') {
|
|
120
|
+
throw new Error(`${response['error']}: ${response['message']}`);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
async simulateDescriptor(params) {
|
|
124
|
+
const response = await this.bidi.send({
|
|
125
|
+
method: 'bluetooth.simulateDescriptor',
|
|
126
|
+
params: params,
|
|
127
|
+
});
|
|
128
|
+
if (response['type'] === 'error') {
|
|
129
|
+
throw new Error(`${response['error']}: ${response['message']}`);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
async simulateDescriptorResponse(params) {
|
|
133
|
+
const response = await this.bidi.send({
|
|
134
|
+
method: 'bluetooth.simulateDescriptorResponse',
|
|
135
|
+
params: params,
|
|
136
|
+
});
|
|
137
|
+
if (response['type'] === 'error') {
|
|
138
|
+
throw new Error(`${response['error']}: ${response['message']}`);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
async onRequestDevicePromptUpdated(callback) {
|
|
142
|
+
await this.bidi.subscribe('bluetooth.requestDevicePromptUpdated');
|
|
143
|
+
this.bidi.on('bluetooth.requestDevicePromptUpdated', (params) => {
|
|
144
|
+
callback(params);
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
async onGattConnectionAttempted(callback) {
|
|
148
|
+
await this.bidi.subscribe('bluetooth.gattConnectionAttempted');
|
|
149
|
+
this.bidi.on('bluetooth.gattConnectionAttempted', (params) => {
|
|
150
|
+
callback(params);
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
exports.Bluetooth = Bluetooth;
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import type { EmptyParams, EmptyResult, JsInt, JsUint } from './common.js';
|
|
2
|
+
import type { SessionProxyConfiguration, SessionUserPromptHandler } from './session.js';
|
|
3
|
+
export type BrowserCommand = BrowserClose | BrowserCreateUserContext | BrowserGetClientWindows | BrowserGetUserContexts | BrowserRemoveUserContext | BrowserSetClientWindowState | BrowserSetDownloadBehavior;
|
|
4
|
+
export type BrowserResult = BrowserCloseResult | BrowserCreateUserContextResult | BrowserGetClientWindowsResult | BrowserGetUserContextsResult | BrowserRemoveUserContextResult | BrowserSetClientWindowStateResult | BrowserSetDownloadBehaviorResult;
|
|
5
|
+
export type BrowserClientWindow = string;
|
|
6
|
+
export interface BrowserClientWindowInfo {
|
|
7
|
+
active: boolean;
|
|
8
|
+
clientWindow: BrowserClientWindow;
|
|
9
|
+
height: JsUint;
|
|
10
|
+
state: "fullscreen" | "maximized" | "minimized" | "normal";
|
|
11
|
+
width: JsUint;
|
|
12
|
+
x: JsInt;
|
|
13
|
+
y: JsInt;
|
|
14
|
+
}
|
|
15
|
+
export type BrowserUserContext = string;
|
|
16
|
+
export interface BrowserUserContextInfo {
|
|
17
|
+
userContext: BrowserUserContext;
|
|
18
|
+
}
|
|
19
|
+
export interface BrowserClose {
|
|
20
|
+
method: "browser.close";
|
|
21
|
+
params: EmptyParams;
|
|
22
|
+
}
|
|
23
|
+
export type BrowserCloseResult = EmptyResult;
|
|
24
|
+
export interface BrowserCreateUserContext {
|
|
25
|
+
method: "browser.createUserContext";
|
|
26
|
+
params: BrowserCreateUserContextParameters;
|
|
27
|
+
}
|
|
28
|
+
export interface BrowserCreateUserContextParameters {
|
|
29
|
+
acceptInsecureCerts?: boolean;
|
|
30
|
+
proxy?: SessionProxyConfiguration;
|
|
31
|
+
unhandledPromptBehavior?: SessionUserPromptHandler;
|
|
32
|
+
}
|
|
33
|
+
export type BrowserCreateUserContextResult = BrowserUserContextInfo;
|
|
34
|
+
export interface BrowserGetClientWindows {
|
|
35
|
+
method: "browser.getClientWindows";
|
|
36
|
+
params: EmptyParams;
|
|
37
|
+
}
|
|
38
|
+
export interface BrowserGetClientWindowsResult {
|
|
39
|
+
clientWindows: BrowserClientWindowInfo[];
|
|
40
|
+
}
|
|
41
|
+
export interface BrowserGetUserContexts {
|
|
42
|
+
method: "browser.getUserContexts";
|
|
43
|
+
params: EmptyParams;
|
|
44
|
+
}
|
|
45
|
+
export interface BrowserGetUserContextsResult {
|
|
46
|
+
userContexts: BrowserUserContextInfo[];
|
|
47
|
+
}
|
|
48
|
+
export interface BrowserRemoveUserContext {
|
|
49
|
+
method: "browser.removeUserContext";
|
|
50
|
+
params: BrowserRemoveUserContextParameters;
|
|
51
|
+
}
|
|
52
|
+
export interface BrowserRemoveUserContextParameters {
|
|
53
|
+
userContext: BrowserUserContext;
|
|
54
|
+
}
|
|
55
|
+
export type BrowserRemoveUserContextResult = EmptyResult;
|
|
56
|
+
export interface BrowserSetClientWindowState {
|
|
57
|
+
method: "browser.setClientWindowState";
|
|
58
|
+
params: BrowserSetClientWindowStateParameters;
|
|
59
|
+
}
|
|
60
|
+
export type BrowserSetClientWindowStateParameters = (BrowserClientWindowNamedState | BrowserClientWindowRectState) & {
|
|
61
|
+
clientWindow: BrowserClientWindow;
|
|
62
|
+
};
|
|
63
|
+
export interface BrowserClientWindowNamedState {
|
|
64
|
+
state: "fullscreen" | "maximized" | "minimized";
|
|
65
|
+
}
|
|
66
|
+
export interface BrowserClientWindowRectState {
|
|
67
|
+
state: "normal";
|
|
68
|
+
width?: JsUint;
|
|
69
|
+
height?: JsUint;
|
|
70
|
+
x?: JsInt;
|
|
71
|
+
y?: JsInt;
|
|
72
|
+
}
|
|
73
|
+
export type BrowserSetClientWindowStateResult = BrowserClientWindowInfo;
|
|
74
|
+
export interface BrowserSetDownloadBehavior {
|
|
75
|
+
method: "browser.setDownloadBehavior";
|
|
76
|
+
params: BrowserSetDownloadBehaviorParameters;
|
|
77
|
+
}
|
|
78
|
+
export interface BrowserSetDownloadBehaviorParameters {
|
|
79
|
+
downloadBehavior: BrowserDownloadBehavior | null;
|
|
80
|
+
userContexts?: BrowserUserContext[];
|
|
81
|
+
}
|
|
82
|
+
export type BrowserDownloadBehavior = (BrowserDownloadBehaviorAllowed | BrowserDownloadBehaviorDenied);
|
|
83
|
+
export interface BrowserDownloadBehaviorAllowed {
|
|
84
|
+
type: "allowed";
|
|
85
|
+
destinationFolder: string;
|
|
86
|
+
}
|
|
87
|
+
export interface BrowserDownloadBehaviorDenied {
|
|
88
|
+
type: "denied";
|
|
89
|
+
}
|
|
90
|
+
export type BrowserSetDownloadBehaviorResult = EmptyResult;
|
|
91
|
+
/** @deprecated Use {@link Browser.create} instead — will be removed in a future major version. */
|
|
92
|
+
export declare function getBrowserInstance(driver: unknown): Promise<Browser>;
|
|
93
|
+
export declare class Browser {
|
|
94
|
+
private readonly bidi;
|
|
95
|
+
private constructor();
|
|
96
|
+
static create(driver: unknown): Promise<Browser>;
|
|
97
|
+
close(): Promise<void>;
|
|
98
|
+
createUserContext(params: BrowserCreateUserContextParameters): Promise<BrowserCreateUserContextResult>;
|
|
99
|
+
getClientWindows(): Promise<BrowserGetClientWindowsResult>;
|
|
100
|
+
getUserContexts(): Promise<BrowserGetUserContextsResult>;
|
|
101
|
+
removeUserContext(params: BrowserRemoveUserContextParameters): Promise<void>;
|
|
102
|
+
setClientWindowState(params: BrowserSetClientWindowStateParameters): Promise<BrowserSetClientWindowStateResult>;
|
|
103
|
+
setDownloadBehavior(params: BrowserSetDownloadBehaviorParameters): Promise<void>;
|
|
104
|
+
}
|
|
@@ -0,0 +1,107 @@
|
|
|
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.Browser = void 0;
|
|
20
|
+
exports.getBrowserInstance = getBrowserInstance;
|
|
21
|
+
// --- Additional Types ---
|
|
22
|
+
/** @deprecated Use {@link Browser.create} instead — will be removed in a future major version. */
|
|
23
|
+
async function getBrowserInstance(driver) {
|
|
24
|
+
return Browser.create(driver);
|
|
25
|
+
}
|
|
26
|
+
// --- Implementation ---
|
|
27
|
+
class Browser {
|
|
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 Browser(bidi);
|
|
38
|
+
}
|
|
39
|
+
async close() {
|
|
40
|
+
const response = await this.bidi.send({
|
|
41
|
+
method: 'browser.close',
|
|
42
|
+
params: {},
|
|
43
|
+
});
|
|
44
|
+
if (response['type'] === 'error') {
|
|
45
|
+
throw new Error(`${response['error']}: ${response['message']}`);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
async createUserContext(params) {
|
|
49
|
+
const response = await this.bidi.send({
|
|
50
|
+
method: 'browser.createUserContext',
|
|
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 getClientWindows() {
|
|
59
|
+
const response = await this.bidi.send({
|
|
60
|
+
method: 'browser.getClientWindows',
|
|
61
|
+
params: {},
|
|
62
|
+
});
|
|
63
|
+
if (response['type'] === 'error') {
|
|
64
|
+
throw new Error(`${response['error']}: ${response['message']}`);
|
|
65
|
+
}
|
|
66
|
+
return response.result;
|
|
67
|
+
}
|
|
68
|
+
async getUserContexts() {
|
|
69
|
+
const response = await this.bidi.send({
|
|
70
|
+
method: 'browser.getUserContexts',
|
|
71
|
+
params: {},
|
|
72
|
+
});
|
|
73
|
+
if (response['type'] === 'error') {
|
|
74
|
+
throw new Error(`${response['error']}: ${response['message']}`);
|
|
75
|
+
}
|
|
76
|
+
return response.result;
|
|
77
|
+
}
|
|
78
|
+
async removeUserContext(params) {
|
|
79
|
+
const response = await this.bidi.send({
|
|
80
|
+
method: 'browser.removeUserContext',
|
|
81
|
+
params: params,
|
|
82
|
+
});
|
|
83
|
+
if (response['type'] === 'error') {
|
|
84
|
+
throw new Error(`${response['error']}: ${response['message']}`);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
async setClientWindowState(params) {
|
|
88
|
+
const response = await this.bidi.send({
|
|
89
|
+
method: 'browser.setClientWindowState',
|
|
90
|
+
params: params,
|
|
91
|
+
});
|
|
92
|
+
if (response['type'] === 'error') {
|
|
93
|
+
throw new Error(`${response['error']}: ${response['message']}`);
|
|
94
|
+
}
|
|
95
|
+
return response.result;
|
|
96
|
+
}
|
|
97
|
+
async setDownloadBehavior(params) {
|
|
98
|
+
const response = await this.bidi.send({
|
|
99
|
+
method: 'browser.setDownloadBehavior',
|
|
100
|
+
params: params,
|
|
101
|
+
});
|
|
102
|
+
if (response['type'] === 'error') {
|
|
103
|
+
throw new Error(`${response['error']}: ${response['message']}`);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
exports.Browser = Browser;
|