@mediar-ai/terminator 0.20.6
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/Cargo.toml +23 -0
- package/README.md +216 -0
- package/build.rs +4 -0
- package/index.d.ts +738 -0
- package/index.js +321 -0
- package/node_example.js +64 -0
- package/package.json +64 -0
- package/src/desktop.rs +520 -0
- package/src/element.rs +581 -0
- package/src/exceptions.rs +58 -0
- package/src/lib.rs +20 -0
- package/src/locator.rs +172 -0
- package/src/selector.rs +139 -0
- package/src/types.rs +308 -0
- package/sync-version.js +60 -0
- package/test-tree.js +83 -0
- package/tests/comprehensive-ui-elements.test.js +524 -0
- package/tests/element-chaining.test.js +158 -0
- package/tests/element-range.test.js +207 -0
- package/tests/element-scroll-into-view.test.js +256 -0
- package/tests/element-value.test.js +264 -0
- package/tests/locator-validate.test.js +260 -0
- package/tests/locator-waitfor.test.js +286 -0
- package/wrapper.d.ts +42 -0
- package/wrapper.js +170 -0
package/index.d.ts
ADDED
|
@@ -0,0 +1,738 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
|
|
4
|
+
/* auto-generated by NAPI-RS */
|
|
5
|
+
|
|
6
|
+
/** Result of element validation */
|
|
7
|
+
export interface ValidationResult {
|
|
8
|
+
/** Whether the element exists */
|
|
9
|
+
exists: boolean
|
|
10
|
+
/** The element if found */
|
|
11
|
+
element?: Element
|
|
12
|
+
/** Error message if validation failed (not element not found, but actual error) */
|
|
13
|
+
error?: string
|
|
14
|
+
}
|
|
15
|
+
export interface Bounds {
|
|
16
|
+
x: number
|
|
17
|
+
y: number
|
|
18
|
+
width: number
|
|
19
|
+
height: number
|
|
20
|
+
}
|
|
21
|
+
export interface Coordinates {
|
|
22
|
+
x: number
|
|
23
|
+
y: number
|
|
24
|
+
}
|
|
25
|
+
export interface ClickResult {
|
|
26
|
+
method: string
|
|
27
|
+
coordinates?: Coordinates
|
|
28
|
+
details: string
|
|
29
|
+
}
|
|
30
|
+
export interface CommandOutput {
|
|
31
|
+
exitStatus?: number
|
|
32
|
+
stdout: string
|
|
33
|
+
stderr: string
|
|
34
|
+
}
|
|
35
|
+
export interface Monitor {
|
|
36
|
+
id: string
|
|
37
|
+
name: string
|
|
38
|
+
isPrimary: boolean
|
|
39
|
+
width: number
|
|
40
|
+
height: number
|
|
41
|
+
x: number
|
|
42
|
+
y: number
|
|
43
|
+
scaleFactor: number
|
|
44
|
+
}
|
|
45
|
+
export interface MonitorScreenshotPair {
|
|
46
|
+
monitor: Monitor
|
|
47
|
+
screenshot: ScreenshotResult
|
|
48
|
+
}
|
|
49
|
+
export interface ScreenshotResult {
|
|
50
|
+
width: number
|
|
51
|
+
height: number
|
|
52
|
+
imageData: Array<number>
|
|
53
|
+
monitor?: Monitor
|
|
54
|
+
}
|
|
55
|
+
export interface UIElementAttributes {
|
|
56
|
+
role: string
|
|
57
|
+
name?: string
|
|
58
|
+
label?: string
|
|
59
|
+
value?: string
|
|
60
|
+
description?: string
|
|
61
|
+
properties: Record<string, string | undefined | null>
|
|
62
|
+
isKeyboardFocusable?: boolean
|
|
63
|
+
bounds?: Bounds
|
|
64
|
+
}
|
|
65
|
+
export interface UINode {
|
|
66
|
+
id?: string
|
|
67
|
+
attributes: UIElementAttributes
|
|
68
|
+
children: Array<UINode>
|
|
69
|
+
}
|
|
70
|
+
export const enum PropertyLoadingMode {
|
|
71
|
+
/** Only load essential properties (role + name) - fastest */
|
|
72
|
+
Fast = 'Fast',
|
|
73
|
+
/** Load all properties for complete element data - slower but comprehensive */
|
|
74
|
+
Complete = 'Complete',
|
|
75
|
+
/** Load specific properties based on element type - balanced approach */
|
|
76
|
+
Smart = 'Smart'
|
|
77
|
+
}
|
|
78
|
+
export interface TreeBuildConfig {
|
|
79
|
+
/** Property loading strategy */
|
|
80
|
+
propertyMode: PropertyLoadingMode
|
|
81
|
+
/** Optional timeout per operation in milliseconds */
|
|
82
|
+
timeoutPerOperationMs?: number
|
|
83
|
+
/** Optional yield frequency for responsiveness */
|
|
84
|
+
yieldEveryNElements?: number
|
|
85
|
+
/** Optional batch size for processing elements */
|
|
86
|
+
batchSize?: number
|
|
87
|
+
}
|
|
88
|
+
export const enum TextPosition {
|
|
89
|
+
Top = 'Top',
|
|
90
|
+
TopRight = 'TopRight',
|
|
91
|
+
Right = 'Right',
|
|
92
|
+
BottomRight = 'BottomRight',
|
|
93
|
+
Bottom = 'Bottom',
|
|
94
|
+
BottomLeft = 'BottomLeft',
|
|
95
|
+
Left = 'Left',
|
|
96
|
+
TopLeft = 'TopLeft',
|
|
97
|
+
Inside = 'Inside'
|
|
98
|
+
}
|
|
99
|
+
export interface FontStyle {
|
|
100
|
+
size: number
|
|
101
|
+
bold: boolean
|
|
102
|
+
color: number
|
|
103
|
+
}
|
|
104
|
+
/** Main entry point for desktop automation. */
|
|
105
|
+
export declare class Desktop {
|
|
106
|
+
/**
|
|
107
|
+
* Create a new Desktop automation instance with configurable options.
|
|
108
|
+
*
|
|
109
|
+
* @param {boolean} [useBackgroundApps=false] - Enable background apps support.
|
|
110
|
+
* @param {boolean} [activateApp=false] - Enable app activation support.
|
|
111
|
+
* @param {string} [logLevel] - Logging level (e.g., 'info', 'debug', 'warn', 'error').
|
|
112
|
+
* @returns {Desktop} A new Desktop automation instance.
|
|
113
|
+
*/
|
|
114
|
+
constructor(useBackgroundApps?: boolean | undefined | null, activateApp?: boolean | undefined | null, logLevel?: string | undefined | null)
|
|
115
|
+
/**
|
|
116
|
+
* Get the root UI element of the desktop.
|
|
117
|
+
*
|
|
118
|
+
* @returns {Element} The root UI element.
|
|
119
|
+
*/
|
|
120
|
+
root(): Element
|
|
121
|
+
/**
|
|
122
|
+
* Get a list of all running applications.
|
|
123
|
+
*
|
|
124
|
+
* @returns {Array<Element>} List of application UI elements.
|
|
125
|
+
*/
|
|
126
|
+
applications(): Array<Element>
|
|
127
|
+
/**
|
|
128
|
+
* Get a running application by name.
|
|
129
|
+
*
|
|
130
|
+
* @param {string} name - The name of the application to find.
|
|
131
|
+
* @returns {Element} The application UI element.
|
|
132
|
+
*/
|
|
133
|
+
application(name: string): Element
|
|
134
|
+
/**
|
|
135
|
+
* Open an application by name.
|
|
136
|
+
*
|
|
137
|
+
* @param {string} name - The name of the application to open.
|
|
138
|
+
*/
|
|
139
|
+
openApplication(name: string): Element
|
|
140
|
+
/**
|
|
141
|
+
* Activate an application by name.
|
|
142
|
+
*
|
|
143
|
+
* @param {string} name - The name of the application to activate.
|
|
144
|
+
*/
|
|
145
|
+
activateApplication(name: string): void
|
|
146
|
+
/**
|
|
147
|
+
* (async) Run a shell command.
|
|
148
|
+
*
|
|
149
|
+
* @param {string} [windowsCommand] - Command to run on Windows.
|
|
150
|
+
* @param {string} [unixCommand] - Command to run on Unix.
|
|
151
|
+
* @returns {Promise<CommandOutput>} The command output.
|
|
152
|
+
*/
|
|
153
|
+
runCommand(windowsCommand?: string | undefined | null, unixCommand?: string | undefined | null): Promise<CommandOutput>
|
|
154
|
+
/**
|
|
155
|
+
* (async) Execute a shell command using GitHub Actions-style syntax.
|
|
156
|
+
*
|
|
157
|
+
* @param {string} command - The command to run (can be single or multi-line).
|
|
158
|
+
* @param {string} [shell] - Optional shell to use (defaults to PowerShell on Windows, bash on Unix).
|
|
159
|
+
* @param {string} [workingDirectory] - Optional working directory for the command.
|
|
160
|
+
* @returns {Promise<CommandOutput>} The command output.
|
|
161
|
+
*/
|
|
162
|
+
run(command: string, shell?: string | undefined | null, workingDirectory?: string | undefined | null): Promise<CommandOutput>
|
|
163
|
+
/**
|
|
164
|
+
* (async) Perform OCR on an image file.
|
|
165
|
+
*
|
|
166
|
+
* @param {string} imagePath - Path to the image file.
|
|
167
|
+
* @returns {Promise<string>} The extracted text.
|
|
168
|
+
*/
|
|
169
|
+
ocrImagePath(imagePath: string): Promise<string>
|
|
170
|
+
/**
|
|
171
|
+
* (async) Perform OCR on a screenshot.
|
|
172
|
+
*
|
|
173
|
+
* @param {ScreenshotResult} screenshot - The screenshot to process.
|
|
174
|
+
* @returns {Promise<string>} The extracted text.
|
|
175
|
+
*/
|
|
176
|
+
ocrScreenshot(screenshot: ScreenshotResult): Promise<string>
|
|
177
|
+
/**
|
|
178
|
+
* (async) Get the currently focused browser window.
|
|
179
|
+
*
|
|
180
|
+
* @returns {Promise<Element>} The current browser window element.
|
|
181
|
+
*/
|
|
182
|
+
getCurrentBrowserWindow(): Promise<Element>
|
|
183
|
+
/**
|
|
184
|
+
* Create a locator for finding UI elements.
|
|
185
|
+
*
|
|
186
|
+
* @param {string | Selector} selector - The selector.
|
|
187
|
+
* @returns {Locator} A locator for finding elements.
|
|
188
|
+
*/
|
|
189
|
+
locator(selector: string | Selector): Locator
|
|
190
|
+
/**
|
|
191
|
+
* (async) Get the currently focused window.
|
|
192
|
+
*
|
|
193
|
+
* @returns {Promise<Element>} The current window element.
|
|
194
|
+
*/
|
|
195
|
+
getCurrentWindow(): Promise<Element>
|
|
196
|
+
/**
|
|
197
|
+
* (async) Get the currently focused application.
|
|
198
|
+
*
|
|
199
|
+
* @returns {Promise<Element>} The current application element.
|
|
200
|
+
*/
|
|
201
|
+
getCurrentApplication(): Promise<Element>
|
|
202
|
+
/**
|
|
203
|
+
* Get the currently focused element.
|
|
204
|
+
*
|
|
205
|
+
* @returns {Element} The focused element.
|
|
206
|
+
*/
|
|
207
|
+
focusedElement(): Element
|
|
208
|
+
/**
|
|
209
|
+
* Open a URL in a browser.
|
|
210
|
+
*
|
|
211
|
+
* @param {string} url - The URL to open.
|
|
212
|
+
* @param {string} [browser] - The browser to use. Can be "Default", "Chrome", "Firefox", "Edge", "Brave", "Opera", "Vivaldi", or a custom browser path.
|
|
213
|
+
*/
|
|
214
|
+
openUrl(url: string, browser?: string | undefined | null): Element
|
|
215
|
+
/**
|
|
216
|
+
* Open a file with its default application.
|
|
217
|
+
*
|
|
218
|
+
* @param {string} filePath - Path to the file to open.
|
|
219
|
+
*/
|
|
220
|
+
openFile(filePath: string): void
|
|
221
|
+
/**
|
|
222
|
+
* Activate a browser window by title.
|
|
223
|
+
*
|
|
224
|
+
* @param {string} title - The window title to match.
|
|
225
|
+
*/
|
|
226
|
+
activateBrowserWindowByTitle(title: string): void
|
|
227
|
+
/**
|
|
228
|
+
* Get the UI tree for a window identified by process ID and optional title.
|
|
229
|
+
*
|
|
230
|
+
* @param {number} pid - Process ID of the target application.
|
|
231
|
+
* @param {string} [title] - Optional window title filter.
|
|
232
|
+
* @param {TreeBuildConfig} [config] - Optional configuration for tree building.
|
|
233
|
+
* @returns {UINode} Complete UI tree starting from the identified window.
|
|
234
|
+
*/
|
|
235
|
+
getWindowTree(pid: number, title?: string | undefined | null, config?: TreeBuildConfig | undefined | null): UINode
|
|
236
|
+
/**
|
|
237
|
+
* (async) List all available monitors/displays.
|
|
238
|
+
*
|
|
239
|
+
* @returns {Promise<Array<Monitor>>} List of monitor information.
|
|
240
|
+
*/
|
|
241
|
+
listMonitors(): Promise<Array<Monitor>>
|
|
242
|
+
/**
|
|
243
|
+
* (async) Get the primary monitor.
|
|
244
|
+
*
|
|
245
|
+
* @returns {Promise<Monitor>} Primary monitor information.
|
|
246
|
+
*/
|
|
247
|
+
getPrimaryMonitor(): Promise<Monitor>
|
|
248
|
+
/**
|
|
249
|
+
* (async) Get the monitor containing the currently focused window.
|
|
250
|
+
*
|
|
251
|
+
* @returns {Promise<Monitor>} Active monitor information.
|
|
252
|
+
*/
|
|
253
|
+
getActiveMonitor(): Promise<Monitor>
|
|
254
|
+
/**
|
|
255
|
+
* (async) Get a monitor by its ID.
|
|
256
|
+
*
|
|
257
|
+
* @param {string} id - The monitor ID to find.
|
|
258
|
+
* @returns {Promise<Monitor>} Monitor information.
|
|
259
|
+
*/
|
|
260
|
+
getMonitorById(id: string): Promise<Monitor>
|
|
261
|
+
/**
|
|
262
|
+
* (async) Get a monitor by its name.
|
|
263
|
+
*
|
|
264
|
+
* @param {string} name - The monitor name to find.
|
|
265
|
+
* @returns {Promise<Monitor>} Monitor information.
|
|
266
|
+
*/
|
|
267
|
+
getMonitorByName(name: string): Promise<Monitor>
|
|
268
|
+
/**
|
|
269
|
+
* (async) Capture a screenshot of a specific monitor.
|
|
270
|
+
*
|
|
271
|
+
* @param {Monitor} monitor - The monitor to capture.
|
|
272
|
+
* @returns {Promise<ScreenshotResult>} The screenshot data.
|
|
273
|
+
*/
|
|
274
|
+
captureMonitor(monitor: Monitor): Promise<ScreenshotResult>
|
|
275
|
+
/**
|
|
276
|
+
* (async) Capture screenshots of all monitors.
|
|
277
|
+
*
|
|
278
|
+
* @returns {Promise<Array<{monitor: Monitor, screenshot: ScreenshotResult}>>} Array of monitor and screenshot pairs.
|
|
279
|
+
*/
|
|
280
|
+
captureAllMonitors(): Promise<Array<MonitorScreenshotPair>>
|
|
281
|
+
/**
|
|
282
|
+
* (async) Get all window elements for a given application name.
|
|
283
|
+
*
|
|
284
|
+
* @param {string} name - The name of the application whose windows will be retrieved.
|
|
285
|
+
* @returns {Promise<Array<Element>>} A list of window elements belonging to the application.
|
|
286
|
+
*/
|
|
287
|
+
windowsForApplication(name: string): Promise<Array<Element>>
|
|
288
|
+
/**
|
|
289
|
+
* (async) Get the UI tree for all open applications in parallel.
|
|
290
|
+
*
|
|
291
|
+
* @returns {Promise<Array<UINode>>} List of UI trees for all applications.
|
|
292
|
+
*/
|
|
293
|
+
getAllApplicationsTree(): Promise<Array<UINode>>
|
|
294
|
+
/**
|
|
295
|
+
* (async) Press a key globally.
|
|
296
|
+
*
|
|
297
|
+
* @param {string} key - The key to press (e.g., "Enter", "Ctrl+C", "F1").
|
|
298
|
+
*/
|
|
299
|
+
pressKey(key: string): Promise<void>
|
|
300
|
+
/**
|
|
301
|
+
* (async) Execute JavaScript in the currently focused browser tab.
|
|
302
|
+
* Automatically finds the active browser window and executes the script.
|
|
303
|
+
*
|
|
304
|
+
* @param {string} script - The JavaScript code to execute in browser context.
|
|
305
|
+
* @returns {Promise<string>} The result of script execution.
|
|
306
|
+
*/
|
|
307
|
+
executeBrowserScript(script: string): Promise<string>
|
|
308
|
+
/**
|
|
309
|
+
* (async) Delay execution for a specified number of milliseconds.
|
|
310
|
+
* Useful for waiting between actions to ensure UI stability.
|
|
311
|
+
*
|
|
312
|
+
* @param {number} delayMs - Delay in milliseconds.
|
|
313
|
+
* @returns {Promise<void>}
|
|
314
|
+
*/
|
|
315
|
+
delay(delayMs: number): Promise<void>
|
|
316
|
+
/**
|
|
317
|
+
* Navigate to a URL in a browser.
|
|
318
|
+
* This is the recommended method for browser navigation - more reliable than
|
|
319
|
+
* manually manipulating the address bar with keyboard/mouse actions.
|
|
320
|
+
*
|
|
321
|
+
* @param {string} url - URL to navigate to
|
|
322
|
+
* @param {string | null} browser - Optional browser name ('Chrome', 'Firefox', 'Edge', 'Brave', 'Opera', 'Vivaldi', or 'Default')
|
|
323
|
+
* @returns {Promise<Element>} The browser window element
|
|
324
|
+
*/
|
|
325
|
+
navigateBrowser(url: string, browser?: string | undefined | null): Element
|
|
326
|
+
/**
|
|
327
|
+
* (async) Set the zoom level to a specific percentage.
|
|
328
|
+
*
|
|
329
|
+
* @param {number} percentage - The zoom percentage (e.g., 100 for 100%, 150 for 150%, 50 for 50%).
|
|
330
|
+
*/
|
|
331
|
+
setZoom(percentage: number): Promise<void>
|
|
332
|
+
}
|
|
333
|
+
/** A UI element in the accessibility tree. */
|
|
334
|
+
export declare class Element {
|
|
335
|
+
/**
|
|
336
|
+
* Get the element's ID.
|
|
337
|
+
*
|
|
338
|
+
* @returns {string | null} The element's ID, if available.
|
|
339
|
+
*/
|
|
340
|
+
id(): string | null
|
|
341
|
+
/**
|
|
342
|
+
* Get the element's role.
|
|
343
|
+
*
|
|
344
|
+
* @returns {string} The element's role (e.g., "button", "textfield").
|
|
345
|
+
*/
|
|
346
|
+
role(): string
|
|
347
|
+
/**
|
|
348
|
+
* Get all attributes of the element.
|
|
349
|
+
*
|
|
350
|
+
* @returns {UIElementAttributes} The element's attributes.
|
|
351
|
+
*/
|
|
352
|
+
attributes(): UIElementAttributes
|
|
353
|
+
/**
|
|
354
|
+
* Get the element's name.
|
|
355
|
+
*
|
|
356
|
+
* @returns {string | null} The element's name, if available.
|
|
357
|
+
*/
|
|
358
|
+
name(): string | null
|
|
359
|
+
/**
|
|
360
|
+
* Get children of this element.
|
|
361
|
+
*
|
|
362
|
+
* @returns {Array<Element>} List of child elements.
|
|
363
|
+
*/
|
|
364
|
+
children(): Array<Element>
|
|
365
|
+
/**
|
|
366
|
+
* Get the parent element.
|
|
367
|
+
*
|
|
368
|
+
* @returns {Element | null} The parent element, if available.
|
|
369
|
+
*/
|
|
370
|
+
parent(): Element | null
|
|
371
|
+
/**
|
|
372
|
+
* Get element bounds.
|
|
373
|
+
*
|
|
374
|
+
* @returns {Bounds} The element's bounds (x, y, width, height).
|
|
375
|
+
*/
|
|
376
|
+
bounds(): Bounds
|
|
377
|
+
/**
|
|
378
|
+
* Click on this element.
|
|
379
|
+
*
|
|
380
|
+
* @returns {ClickResult} Result of the click operation.
|
|
381
|
+
*/
|
|
382
|
+
click(): ClickResult
|
|
383
|
+
/**
|
|
384
|
+
* Double click on this element.
|
|
385
|
+
*
|
|
386
|
+
* @returns {ClickResult} Result of the click operation.
|
|
387
|
+
*/
|
|
388
|
+
doubleClick(): ClickResult
|
|
389
|
+
/** Right click on this element. */
|
|
390
|
+
rightClick(): void
|
|
391
|
+
/** Hover over this element. */
|
|
392
|
+
hover(): void
|
|
393
|
+
/**
|
|
394
|
+
* Check if element is visible.
|
|
395
|
+
*
|
|
396
|
+
* @returns {boolean} True if the element is visible.
|
|
397
|
+
*/
|
|
398
|
+
isVisible(): boolean
|
|
399
|
+
/**
|
|
400
|
+
* Check if element is enabled.
|
|
401
|
+
*
|
|
402
|
+
* @returns {boolean} True if the element is enabled.
|
|
403
|
+
*/
|
|
404
|
+
isEnabled(): boolean
|
|
405
|
+
/** Focus this element. */
|
|
406
|
+
focus(): void
|
|
407
|
+
/**
|
|
408
|
+
* Get text content of this element.
|
|
409
|
+
*
|
|
410
|
+
* @param {number} [maxDepth] - Maximum depth to search for text.
|
|
411
|
+
* @returns {string} The element's text content.
|
|
412
|
+
*/
|
|
413
|
+
text(maxDepth?: number | undefined | null): string
|
|
414
|
+
/**
|
|
415
|
+
* Type text into this element.
|
|
416
|
+
*
|
|
417
|
+
* @param {string} text - The text to type.
|
|
418
|
+
* @param {boolean} [useClipboard] - Whether to use clipboard for pasting.
|
|
419
|
+
*/
|
|
420
|
+
typeText(text: string, useClipboard?: boolean | undefined | null): void
|
|
421
|
+
/**
|
|
422
|
+
* Press a key while this element is focused.
|
|
423
|
+
*
|
|
424
|
+
* @param {string} key - The key to press.
|
|
425
|
+
*/
|
|
426
|
+
pressKey(key: string): void
|
|
427
|
+
/**
|
|
428
|
+
* Set value of this element.
|
|
429
|
+
*
|
|
430
|
+
* @param {string} value - The value to set.
|
|
431
|
+
*/
|
|
432
|
+
setValue(value: string): void
|
|
433
|
+
/**
|
|
434
|
+
* Perform a named action on this element.
|
|
435
|
+
*
|
|
436
|
+
* @param {string} action - The action to perform.
|
|
437
|
+
*/
|
|
438
|
+
performAction(action: string): void
|
|
439
|
+
/**
|
|
440
|
+
* Invoke this element (triggers the default action).
|
|
441
|
+
* This is often more reliable than clicking for controls like radio buttons or menu items.
|
|
442
|
+
*/
|
|
443
|
+
invoke(): void
|
|
444
|
+
/**
|
|
445
|
+
* Scroll the element in a given direction.
|
|
446
|
+
*
|
|
447
|
+
* @param {string} direction - The direction to scroll.
|
|
448
|
+
* @param {number} amount - The amount to scroll.
|
|
449
|
+
*/
|
|
450
|
+
scroll(direction: string, amount: number): void
|
|
451
|
+
/** Activate the window containing this element. */
|
|
452
|
+
activateWindow(): void
|
|
453
|
+
/** Minimize the window containing this element. */
|
|
454
|
+
minimizeWindow(): void
|
|
455
|
+
/** Maximize the window containing this element. */
|
|
456
|
+
maximizeWindow(): void
|
|
457
|
+
/**
|
|
458
|
+
* Check if element is focused.
|
|
459
|
+
*
|
|
460
|
+
* @returns {boolean} True if the element is focused.
|
|
461
|
+
*/
|
|
462
|
+
isFocused(): boolean
|
|
463
|
+
/**
|
|
464
|
+
* Check if element is keyboard focusable.
|
|
465
|
+
*
|
|
466
|
+
* @returns {boolean} True if the element can receive keyboard focus.
|
|
467
|
+
*/
|
|
468
|
+
isKeyboardFocusable(): boolean
|
|
469
|
+
/**
|
|
470
|
+
* Drag mouse from start to end coordinates.
|
|
471
|
+
*
|
|
472
|
+
* @param {number} startX - Starting X coordinate.
|
|
473
|
+
* @param {number} startY - Starting Y coordinate.
|
|
474
|
+
* @param {number} endX - Ending X coordinate.
|
|
475
|
+
* @param {number} endY - Ending Y coordinate.
|
|
476
|
+
*/
|
|
477
|
+
mouseDrag(startX: number, startY: number, endX: number, endY: number): void
|
|
478
|
+
/**
|
|
479
|
+
* Press and hold mouse at coordinates.
|
|
480
|
+
*
|
|
481
|
+
* @param {number} x - X coordinate.
|
|
482
|
+
* @param {number} y - Y coordinate.
|
|
483
|
+
*/
|
|
484
|
+
mouseClickAndHold(x: number, y: number): void
|
|
485
|
+
/**
|
|
486
|
+
* Move mouse to coordinates.
|
|
487
|
+
*
|
|
488
|
+
* @param {number} x - X coordinate.
|
|
489
|
+
* @param {number} y - Y coordinate.
|
|
490
|
+
*/
|
|
491
|
+
mouseMove(x: number, y: number): void
|
|
492
|
+
/** Release mouse button. */
|
|
493
|
+
mouseRelease(): void
|
|
494
|
+
/**
|
|
495
|
+
* Create a locator from this element.
|
|
496
|
+
* Accepts either a selector string or a Selector object.
|
|
497
|
+
*
|
|
498
|
+
* @param {string | Selector} selector - The selector.
|
|
499
|
+
* @returns {Locator} A new locator for finding elements.
|
|
500
|
+
*/
|
|
501
|
+
locator(selector: string | Selector): Locator
|
|
502
|
+
/**
|
|
503
|
+
* Get the containing application element.
|
|
504
|
+
*
|
|
505
|
+
* @returns {Element | null} The containing application element, if available.
|
|
506
|
+
*/
|
|
507
|
+
application(): Element | null
|
|
508
|
+
/**
|
|
509
|
+
* Get the containing window element.
|
|
510
|
+
*
|
|
511
|
+
* @returns {Element | null} The containing window element, if available.
|
|
512
|
+
*/
|
|
513
|
+
window(): Element | null
|
|
514
|
+
/**
|
|
515
|
+
* Highlights the element with a colored border and optional text overlay.
|
|
516
|
+
*
|
|
517
|
+
* @param {number} [color] - Optional BGR color code (32-bit integer). Default: 0x0000FF (red)
|
|
518
|
+
* @param {number} [durationMs] - Optional duration in milliseconds.
|
|
519
|
+
* @param {string} [text] - Optional text to display. Text will be truncated to 10 characters.
|
|
520
|
+
* @param {TextPosition} [textPosition] - Optional position for the text overlay (default: Top)
|
|
521
|
+
* @param {FontStyle} [fontStyle] - Optional font styling for the text
|
|
522
|
+
* @returns {HighlightHandle} Handle that can be used to close the highlight early
|
|
523
|
+
*/
|
|
524
|
+
highlight(color?: number | undefined | null, durationMs?: number | undefined | null, text?: string | undefined | null, textPosition?: TextPosition | undefined | null, fontStyle?: FontStyle | undefined | null): HighlightHandle
|
|
525
|
+
/**
|
|
526
|
+
* Capture a screenshot of this element.
|
|
527
|
+
*
|
|
528
|
+
* @returns {ScreenshotResult} The screenshot data containing image data and dimensions.
|
|
529
|
+
*/
|
|
530
|
+
capture(): ScreenshotResult
|
|
531
|
+
/**
|
|
532
|
+
* Get the process ID of the application containing this element.
|
|
533
|
+
*
|
|
534
|
+
* @returns {number} The process ID.
|
|
535
|
+
*/
|
|
536
|
+
processId(): number
|
|
537
|
+
toString(): string
|
|
538
|
+
/**
|
|
539
|
+
* Sets the transparency of the window.
|
|
540
|
+
*
|
|
541
|
+
* @param {number} percentage - The transparency percentage from 0 (completely transparent) to 100 (completely opaque).
|
|
542
|
+
* @returns {void}
|
|
543
|
+
*/
|
|
544
|
+
setTransparency(percentage: number): void
|
|
545
|
+
/**
|
|
546
|
+
* Close the element if it's closable (like windows, applications).
|
|
547
|
+
* Does nothing for non-closable elements (like buttons, text, etc.).
|
|
548
|
+
*
|
|
549
|
+
* @returns {void}
|
|
550
|
+
*/
|
|
551
|
+
close(): void
|
|
552
|
+
/**
|
|
553
|
+
* Get the monitor containing this element.
|
|
554
|
+
*
|
|
555
|
+
* @returns {Monitor} The monitor information for the display containing this element.
|
|
556
|
+
*/
|
|
557
|
+
monitor(): Monitor
|
|
558
|
+
/**
|
|
559
|
+
* Scrolls the element into view within its window viewport.
|
|
560
|
+
* If the element is already visible, returns immediately.
|
|
561
|
+
*
|
|
562
|
+
* @returns {void}
|
|
563
|
+
*/
|
|
564
|
+
scrollIntoView(): void
|
|
565
|
+
/**
|
|
566
|
+
* Selects an option in a dropdown or combobox by its visible text.
|
|
567
|
+
*
|
|
568
|
+
* @param {string} optionName - The visible text of the option to select.
|
|
569
|
+
* @returns {void}
|
|
570
|
+
*/
|
|
571
|
+
selectOption(optionName: string): void
|
|
572
|
+
/**
|
|
573
|
+
* Lists all available option strings from a dropdown or list box.
|
|
574
|
+
*
|
|
575
|
+
* @returns {Array<string>} List of available option strings.
|
|
576
|
+
*/
|
|
577
|
+
listOptions(): Array<string>
|
|
578
|
+
/**
|
|
579
|
+
* Checks if a control (like a checkbox or toggle switch) is currently toggled on.
|
|
580
|
+
*
|
|
581
|
+
* @returns {boolean} True if the control is toggled on.
|
|
582
|
+
*/
|
|
583
|
+
isToggled(): boolean
|
|
584
|
+
/**
|
|
585
|
+
* Sets the state of a toggleable control.
|
|
586
|
+
* It only performs an action if the control is not already in the desired state.
|
|
587
|
+
*
|
|
588
|
+
* @param {boolean} state - The desired toggle state.
|
|
589
|
+
* @returns {void}
|
|
590
|
+
*/
|
|
591
|
+
setToggled(state: boolean): void
|
|
592
|
+
/**
|
|
593
|
+
* Checks if an element is selected (e.g., list item, tree node, tab).
|
|
594
|
+
*
|
|
595
|
+
* @returns {boolean} True if the element is selected, false otherwise.
|
|
596
|
+
*/
|
|
597
|
+
isSelected(): boolean
|
|
598
|
+
/**
|
|
599
|
+
* Sets the selection state of a selectable item.
|
|
600
|
+
* Only performs an action if the element is not already in the desired state.
|
|
601
|
+
*
|
|
602
|
+
* @param {boolean} state - The desired selection state.
|
|
603
|
+
* @returns {void}
|
|
604
|
+
*/
|
|
605
|
+
setSelected(state: boolean): void
|
|
606
|
+
/**
|
|
607
|
+
* Gets the current value from a range-based control like a slider or progress bar.
|
|
608
|
+
*
|
|
609
|
+
* @returns {number} The current value of the range control.
|
|
610
|
+
*/
|
|
611
|
+
getRangeValue(): number
|
|
612
|
+
/**
|
|
613
|
+
* Sets the value of a range-based control like a slider.
|
|
614
|
+
*
|
|
615
|
+
* @param {number} value - The value to set.
|
|
616
|
+
* @returns {void}
|
|
617
|
+
*/
|
|
618
|
+
setRangeValue(value: number): void
|
|
619
|
+
/**
|
|
620
|
+
* Gets the value attribute of an element (text inputs, combo boxes, etc.).
|
|
621
|
+
*
|
|
622
|
+
* @returns {string | null} The value attribute, or null if not available.
|
|
623
|
+
*/
|
|
624
|
+
getValue(): string | null
|
|
625
|
+
/**
|
|
626
|
+
* Execute JavaScript in web browser using dev tools console.
|
|
627
|
+
* Returns the result of the script execution as a string.
|
|
628
|
+
*
|
|
629
|
+
* @param {string} script - The JavaScript code to execute.
|
|
630
|
+
* @returns {Promise<string>} The result of script execution.
|
|
631
|
+
*/
|
|
632
|
+
executeBrowserScript(script: string): Promise<string>
|
|
633
|
+
/**
|
|
634
|
+
* Get the UI tree starting from this element.
|
|
635
|
+
* Returns a tree structure containing this element and all its descendants.
|
|
636
|
+
*
|
|
637
|
+
* @param {number} [maxDepth=100] - Maximum depth to traverse (default: 100).
|
|
638
|
+
* @returns {UINode} Tree structure with recursive children.
|
|
639
|
+
*/
|
|
640
|
+
getTree(maxDepth?: number | undefined | null): UINode
|
|
641
|
+
}
|
|
642
|
+
/** Locator for finding UI elements by selector. */
|
|
643
|
+
export declare class Locator {
|
|
644
|
+
/**
|
|
645
|
+
* (async) Get the first matching element.
|
|
646
|
+
*
|
|
647
|
+
* @param {number} timeoutMs - Timeout in milliseconds (required).
|
|
648
|
+
* @returns {Promise<Element>} The first matching element.
|
|
649
|
+
*/
|
|
650
|
+
first(timeoutMs: number): Promise<Element>
|
|
651
|
+
/**
|
|
652
|
+
* (async) Get all matching elements.
|
|
653
|
+
*
|
|
654
|
+
* @param {number} timeoutMs - Timeout in milliseconds (required).
|
|
655
|
+
* @param {number} [depth] - Maximum depth to search.
|
|
656
|
+
* @returns {Promise<Array<Element>>} List of matching elements.
|
|
657
|
+
*/
|
|
658
|
+
all(timeoutMs: number, depth?: number | undefined | null): Promise<Array<Element>>
|
|
659
|
+
/**
|
|
660
|
+
* Set a default timeout for this locator.
|
|
661
|
+
*
|
|
662
|
+
* @param {number} timeoutMs - Timeout in milliseconds.
|
|
663
|
+
* @returns {Locator} A new locator with the specified timeout.
|
|
664
|
+
*/
|
|
665
|
+
timeout(timeoutMs: number): Locator
|
|
666
|
+
/**
|
|
667
|
+
* Set the root element for this locator.
|
|
668
|
+
*
|
|
669
|
+
* @param {Element} element - The root element.
|
|
670
|
+
* @returns {Locator} A new locator with the specified root element.
|
|
671
|
+
*/
|
|
672
|
+
within(element: Element): Locator
|
|
673
|
+
/**
|
|
674
|
+
* Chain another selector.
|
|
675
|
+
* Accepts either a selector string or a Selector object.
|
|
676
|
+
*
|
|
677
|
+
* @param {string | Selector} selector - The selector.
|
|
678
|
+
* @returns {Locator} A new locator with the chained selector.
|
|
679
|
+
*/
|
|
680
|
+
locator(selector: string | Selector): Locator
|
|
681
|
+
/**
|
|
682
|
+
* (async) Validate element existence without throwing an error.
|
|
683
|
+
*
|
|
684
|
+
* @param {number} timeoutMs - Timeout in milliseconds (required).
|
|
685
|
+
* @returns {Promise<ValidationResult>} Validation result with exists flag and optional element.
|
|
686
|
+
*/
|
|
687
|
+
validate(timeoutMs: number): Promise<ValidationResult>
|
|
688
|
+
/**
|
|
689
|
+
* (async) Wait for an element to meet a specific condition.
|
|
690
|
+
*
|
|
691
|
+
* @param {string} condition - Condition to wait for: 'exists', 'visible', 'enabled', 'focused'
|
|
692
|
+
* @param {number} timeoutMs - Timeout in milliseconds (required).
|
|
693
|
+
* @returns {Promise<Element>} The element when condition is met.
|
|
694
|
+
*/
|
|
695
|
+
waitFor(condition: string, timeoutMs: number): Promise<Element>
|
|
696
|
+
}
|
|
697
|
+
/** Selector for locating UI elements. Provides a typed alternative to the string based selector API. */
|
|
698
|
+
export declare class Selector {
|
|
699
|
+
/** Create a selector that matches elements by their accessibility `name`. */
|
|
700
|
+
static name(name: string): Selector
|
|
701
|
+
/** Create a selector that matches elements by role (and optionally name). */
|
|
702
|
+
static role(role: string, name?: string | undefined | null): Selector
|
|
703
|
+
/** Create a selector that matches elements by accessibility `id`. */
|
|
704
|
+
static id(id: string): Selector
|
|
705
|
+
/** Create a selector that matches elements by the text they display. */
|
|
706
|
+
static text(text: string): Selector
|
|
707
|
+
/** Create a selector from an XPath-like path string. */
|
|
708
|
+
static path(path: string): Selector
|
|
709
|
+
/** Create a selector that matches elements by a native automation id (e.g., AutomationID on Windows). */
|
|
710
|
+
static nativeId(id: string): Selector
|
|
711
|
+
/** Create a selector that matches elements by their class name. */
|
|
712
|
+
static className(name: string): Selector
|
|
713
|
+
/** Create a selector from an arbitrary attribute map. */
|
|
714
|
+
static attributes(attributes: Record<string, string>): Selector
|
|
715
|
+
/** Chain another selector onto this selector. */
|
|
716
|
+
chain(other: Selector): Selector
|
|
717
|
+
/** Filter by visibility. */
|
|
718
|
+
visible(isVisible: boolean): Selector
|
|
719
|
+
/**
|
|
720
|
+
* Create a selector that selects the nth element from matches.
|
|
721
|
+
* Positive values are 0-based from the start (0 = first, 1 = second).
|
|
722
|
+
* Negative values are from the end (-1 = last, -2 = second-to-last).
|
|
723
|
+
*/
|
|
724
|
+
static nth(index: number): Selector
|
|
725
|
+
/**
|
|
726
|
+
* Create a selector that matches elements having at least one descendant matching the inner selector.
|
|
727
|
+
* This is similar to Playwright's :has() pseudo-class.
|
|
728
|
+
*/
|
|
729
|
+
static has(innerSelector: Selector): Selector
|
|
730
|
+
/**
|
|
731
|
+
* Create a selector that navigates to the parent element.
|
|
732
|
+
* This is similar to Playwright's .. syntax.
|
|
733
|
+
*/
|
|
734
|
+
static parent(): Selector
|
|
735
|
+
}
|
|
736
|
+
export declare class HighlightHandle {
|
|
737
|
+
close(): void
|
|
738
|
+
}
|