appium-novawindows2-driver 0.2.4 → 0.2.5
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/LICENSE +201 -201
- package/README.md +554 -554
- package/build/lib/commands/app.js +35 -35
- package/build/lib/commands/extension.js +26 -26
- package/build/lib/commands/file.js +22 -22
- package/build/lib/commands/functions.js +189 -189
- package/build/lib/commands/index.d.ts +3 -3
- package/build/lib/commands/index.d.ts.map +1 -1
- package/build/lib/commands/powershell.d.ts.map +1 -1
- package/build/lib/commands/powershell.js +27 -20
- package/build/lib/commands/powershell.js.map +1 -1
- package/build/lib/powershell/elements.d.ts.map +1 -1
- package/build/lib/powershell/elements.js +747 -739
- package/build/lib/powershell/elements.js.map +1 -1
- package/build/lib/powershell/msaa.js +96 -96
- package/build/tsconfig.tsbuildinfo +1 -1
- package/package.json +64 -64
- package/build/lib/temp/MSAAHelper.dll +0 -0
- package/build/lib/winapi/uia.d.ts +0 -163
- package/build/lib/winapi/uia.d.ts.map +0 -1
- package/build/lib/winapi/uia.js +0 -677
- package/build/lib/winapi/uia.js.map +0 -1
- package/build/lib/xpath/native.d.ts +0 -14
- package/build/lib/xpath/native.d.ts.map +0 -1
- package/build/lib/xpath/native.js +0 -329
- package/build/lib/xpath/native.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,554 +1,554 @@
|
|
|
1
|
-
NovaWindows2 Driver
|
|
2
|
-
===================
|
|
3
|
-
|
|
4
|
-
NovaWindows2 Driver is a custom Appium driver designed to tackle the limitations of existing Windows automation solutions like WinAppDriver. It supports testing Universal Windows Platform (UWP), Windows Forms (WinForms), Windows Presentation Foundation (WPF), and Classic Windows (Win32) apps on Windows 10 and later.
|
|
5
|
-
|
|
6
|
-
Built to improve performance and reliability for traditional desktop applications, it offers:
|
|
7
|
-
- **Faster XPath locator performance** — Reduces element lookup times, even in complex UIs.
|
|
8
|
-
- **RawView element support** — Access elements typically hidden from the default ControlView/ContentView.
|
|
9
|
-
- **Enhanced text input handling** — Fast text entry with support for various keyboard layouts.
|
|
10
|
-
- **Platform-specific commands** — Supports direct window manipulation, advanced UI interactions, and more.
|
|
11
|
-
- **Seamless Setup** — Designed to work without Developer Mode or additional software.
|
|
12
|
-
|
|
13
|
-
---
|
|
14
|
-
|
|
15
|
-
## 📑 Table of Contents
|
|
16
|
-
- [Getting Started](#-getting-started)
|
|
17
|
-
- [Configuration](#-configuration)
|
|
18
|
-
- [Example Usage](#-example-usage)
|
|
19
|
-
- [Key Features](#-key-features)
|
|
20
|
-
- [Element Location](#element-location)
|
|
21
|
-
- [Attribute Retrieval](#attribute-retrieval)
|
|
22
|
-
- [PowerShell Execution](#powershell-execution)
|
|
23
|
-
- [Platform-Specific Extensions](#-platform-specific-extensions)
|
|
24
|
-
- [Mouse & Pointer](#mouse--pointer)
|
|
25
|
-
- [Keyboard](#keyboard)
|
|
26
|
-
- [Element Operations](#element-operations)
|
|
27
|
-
- [Selection Management](#selection-management)
|
|
28
|
-
- [Window Management](#window-management)
|
|
29
|
-
- [System & State](#system--state)
|
|
30
|
-
- [Development](#-development)
|
|
31
|
-
|
|
32
|
-
---
|
|
33
|
-
|
|
34
|
-
## 🚀 Getting Started
|
|
35
|
-
|
|
36
|
-
### Installation
|
|
37
|
-
The driver is built for Appium 3. To install it, run:
|
|
38
|
-
```bash
|
|
39
|
-
appium driver install --source=npm appium-novawindows2-driver
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
### Prerequisites
|
|
43
|
-
- **Host OS**: Windows 10 or later.
|
|
44
|
-
- No Developer Mode or extra dependencies required.
|
|
45
|
-
|
|
46
|
-
---
|
|
47
|
-
|
|
48
|
-
## ⚙️ Configuration
|
|
49
|
-
|
|
50
|
-
NovaWindows2 Driver supports the following capabilities:
|
|
51
|
-
|
|
52
|
-
| Capability Name | Description | Default | Example |
|
|
53
|
-
| :--- | :--- | :--- | :--- |
|
|
54
|
-
| `platformName` | Must be set to `Windows` (case-insensitive). | (Required) | `Windows` |
|
|
55
|
-
| `automationName` | Must be set to `NovaWindows2` (case-insensitive). | (Required) | `NovaWindows2` |
|
|
56
|
-
| `smoothPointerMove` | CSS-like easing function (including valid Bezier curve). This controls the smooth movement of the mouse for `delayBeforeClick` ms. | (None) | `ease-in`, `cubic-bezier(0.42, 0, 0.58, 1)` |
|
|
57
|
-
| `delayBeforeClick` | Time in milliseconds before a click is performed. | `0` | `500` |
|
|
58
|
-
| `delayAfterClick` | Time in milliseconds after a click is performed. | `0` | `500` |
|
|
59
|
-
| `appTopLevelWindow` | The handle of an existing application top-level window to attach to. It can be a number or string (not necessarily hexadecimal). | (None) | `12345`, `0x12345` |
|
|
60
|
-
| `shouldCloseApp` | Whether to close the window of the application in test after the session finishes. | `true` | `false` |
|
|
61
|
-
| `appArguments` | Optional string of arguments to pass to the app on launch. | (None) | `--debug` |
|
|
62
|
-
| `appWorkingDir` | Optional working directory path for the application. | (None) | `C:\Temp` |
|
|
63
|
-
| `prerun` | An object containing either `script` or `command` key. The value of each key must be a valid PowerShell script or command to be executed prior to the WinAppDriver session startup. See [Power Shell commands execution](#powershell-execution) for more details. | (None) | `{script: 'Get-Process outlook -ErrorAction SilentlyContinue'}` |
|
|
64
|
-
| `postrun` | An object containing either `script` or `command` key. The value of each key must be a valid PowerShell script or command to be executed after WinAppDriver session is stopped. See [Power Shell commands execution](#powershell-execution) for more details. | (None) | `{command: '...'}` |
|
|
65
|
-
| `isolatedScriptExecution` | Whether PowerShell scripts are executed in an isolated session. | `false` | `true` |
|
|
66
|
-
| `appWaitForLaunchRetries` | Number of retries when waiting for the app to launch. | `20` | `5` |
|
|
67
|
-
| `appWaitForLaunchRetryIntervalMs` | Interval (ms) between app launch check retries. | `500` | `500` |
|
|
68
|
-
| `powerShellCommandTimeout` | Timeout (ms) for PowerShell script execution. | `60000` | `30000` |
|
|
69
|
-
| `convertAbsoluteXPathToRelativeFromElement` | Convert absolute XPath to relative when searching from an element. | `true` | `true` |
|
|
70
|
-
| `includeContextElementInSearch` | Include the context element itself in the search. | `true` | `true` |
|
|
71
|
-
| `releaseModifierKeys` | Whether to release modifier keys after `sendKeys`. | `true` | `true` |
|
|
72
|
-
| `typeDelay` | Time in milliseconds to wait after inputting each character. Note that this delay does not apply to modifier keys (Shift, Ctrl, Alt, Win). | `0` | `100` |
|
|
73
|
-
|
|
74
|
-
---
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
## 💡 Example Usage
|
|
79
|
-
|
|
80
|
-
Check out the [examples/refactor](examples/refactor) directory for comprehensive examples.
|
|
81
|
-
|
|
82
|
-
### Python (Appium-Python-Client)
|
|
83
|
-
```python
|
|
84
|
-
from appium import webdriver
|
|
85
|
-
from appium.options.windows import WindowsOptions
|
|
86
|
-
|
|
87
|
-
options = WindowsOptions()
|
|
88
|
-
options.app = 'C:\\Windows\\System32\\notepad.exe'
|
|
89
|
-
options.automation_name = 'NovaWindows2'
|
|
90
|
-
|
|
91
|
-
driver = webdriver.Remote('http://127.0.0.1:4723', options=options)
|
|
92
|
-
# ... tests ...
|
|
93
|
-
driver.quit()
|
|
94
|
-
```
|
|
95
|
-
|
|
96
|
-
---
|
|
97
|
-
|
|
98
|
-
## ✨ Key Features
|
|
99
|
-
|
|
100
|
-
### Element Location
|
|
101
|
-
Appium Windows Driver supports the same location strategies [the WinAppDriver supports](https://github.com/microsoft/WinAppDriver/blob/master/Docs/AuthoringTestScripts.md#supported-locators-to-find-ui-elements), but also includes Windows UIAutomation conditions:
|
|
102
|
-
|
|
103
|
-
| Name | Description | Example |
|
|
104
|
-
| :--- | :--- | :--- |
|
|
105
|
-
| `accessibility id` | This strategy is `AutomationId` attribute in inspect.exe | `CalculatorResults` |
|
|
106
|
-
| `class name` | This strategy is `ClassName` attribute in inspect.exe | `TextBlock` |
|
|
107
|
-
| `id` | This strategy is `RuntimeId` (decimal) attribute in inspect.exe | `42.333896.3.1` |
|
|
108
|
-
| `name` | This strategy is `Name` attribute in inspect.exe | `Calculator` |
|
|
109
|
-
| `tag name` | This strategy is `LocalizedControlType` (upper camel case) attribute in inspect.exe | `Text` |
|
|
110
|
-
| `xpath` | Custom XPath 1.0 queries on any attribute exposed by inspect.exe. | `(//Button)[2]` |
|
|
111
|
-
| `windows uiautomation` | UIAutomation conditions (C# or PowerShell syntax). | `new PropertyCondition(...)` |
|
|
112
|
-
|
|
113
|
-
### Attribute Retrieval
|
|
114
|
-
Retrieve comprehensive details about UI elements using standard or bulk methods.
|
|
115
|
-
|
|
116
|
-
- **Bulk Retrieval**: Use the `"all"` keyword to get 80+ properties in a single JSON object.
|
|
117
|
-
- **Dotted Names**: Access pattern-specific properties directly (e.g., `Window.CanMaximize`, `LegacyIAccessible.Name`).
|
|
118
|
-
|
|
119
|
-
```js
|
|
120
|
-
// getAttributes returns all properties as a JSON string
|
|
121
|
-
const allAttributes = await element.getAttribute("all");
|
|
122
|
-
```
|
|
123
|
-
|
|
124
|
-
### PowerShell Execution
|
|
125
|
-
Execute internal PowerShell scripts or commands directly from your test. This requires the `power_shell` insecure feature to be enabled on the Appium server.
|
|
126
|
-
|
|
127
|
-
It is possible to execute a single PowerShell command or a whole script. Note that `powerShell` is case-insensitive.
|
|
128
|
-
|
|
129
|
-
```javascript
|
|
130
|
-
// Execute a command string
|
|
131
|
-
await driver.executeScript('powerShell', { command: 'Get-Process Notepad' });
|
|
132
|
-
|
|
133
|
-
// Execute a script string
|
|
134
|
-
await driver.executeScript('powerShell', { script: '$p = Get-Process Notepad; $p.Kill();' });
|
|
135
|
-
|
|
136
|
-
// Shorthand (executes as command/script depending on context)
|
|
137
|
-
await driver.executeScript('powerShell', 'Get-Process');
|
|
138
|
-
```
|
|
139
|
-
|
|
140
|
-
### Enhanced Text Input
|
|
141
|
-
You can specify the delay directly within the text string using the `[delay:ms]` pattern. This overrides the session setting (set via `windows: typeDelay` or `typeDelay` capability) for that specific action.
|
|
142
|
-
|
|
143
|
-
```python
|
|
144
|
-
driver.find_element(...).send_keys("[delay:500]Slow text")
|
|
145
|
-
```
|
|
146
|
-
|
|
147
|
-
---
|
|
148
|
-
|
|
149
|
-
## 🛠 Platform-Specific Extensions
|
|
150
|
-
|
|
151
|
-
All extensions are invoked via `driver.executeScript("windows: <methodName>", ...args)`.
|
|
152
|
-
Below are the detailed descriptions and arguments for each command.
|
|
153
|
-
|
|
154
|
-
> **Note**
|
|
155
|
-
> In most cases, commands can be used more intuitively by passing the element as the first argument (if required) and other parameters subsequently.
|
|
156
|
-
|
|
157
|
-
### Mouse & Pointer
|
|
158
|
-
|
|
159
|
-
#### `windows: click`
|
|
160
|
-
This is a shortcut for a single mouse click gesture.
|
|
161
|
-
|
|
162
|
-
| Name | Type | Required | Description | Example |
|
|
163
|
-
| :--- | :--- | :--- | :--- | :--- |
|
|
164
|
-
| `elementId` | `string` | no | Hexadecimal identifier of the element to click on. If this parameter is missing then given coordinates will be parsed as absolute ones. Otherwise they are parsed as relative to the top left corner of this element. | `123e4567-e89b...` |
|
|
165
|
-
| `x` | `number` | no | Integer horizontal coordinate of the click point. Both x and y coordinates must be provided or none of them if elementId is present. | `100` |
|
|
166
|
-
| `y` | `number` | no | Integer vertical coordinate of the click point. Both x and y coordinates must be provided or none of them if elementId is present. | `100` |
|
|
167
|
-
| `button` | `string` | no | Name of the mouse button to be clicked. Supported button names are: `left`, `middle`, `right`, `back`, `forward`. The default value is `left`. | `right` |
|
|
168
|
-
| `modifierKeys` | `string[]` \| `string` | no | List of possible keys or a single key name to depress while the click is being performed. Supported key names are: `Shift`, `Ctrl`, `Alt`, `Win`. | `['ctrl', 'alt']` |
|
|
169
|
-
| `durationMs` | `number` | no | The number of milliseconds to wait between pressing and releasing the mouse button. By default no delay is applied. | `500` |
|
|
170
|
-
| `times` | `number` | no | How many times the click must be performed. One by default. | `2` |
|
|
171
|
-
| `interClickDelayMs` | `number` | no | Duration of the pause between each click gesture. Only makes sense if `times` is greater than one. 100ms by default. | `10` |
|
|
172
|
-
|
|
173
|
-
#### Usage
|
|
174
|
-
```python
|
|
175
|
-
driver.execute_script('windows: click', {
|
|
176
|
-
'elementId': element.id,
|
|
177
|
-
'button': 'right',
|
|
178
|
-
'times': 2,
|
|
179
|
-
'modifierKeys': ['ctrl', 'alt']
|
|
180
|
-
})
|
|
181
|
-
```
|
|
182
|
-
|
|
183
|
-
#### `windows: scroll`
|
|
184
|
-
This is a shortcut for a mouse wheel scroll gesture. The API is a thin wrapper over the SendInput WinApi call.
|
|
185
|
-
|
|
186
|
-
| Name | Type | Required | Description | Example |
|
|
187
|
-
| :--- | :--- | :--- | :--- | :--- |
|
|
188
|
-
| `elementId` | `string` | no | Same as in `windows: click`. | `123e4567-e89b...` |
|
|
189
|
-
| `x` | `number` | no | Same as in `windows: click`. | `100` |
|
|
190
|
-
| `y` | `number` | no | Same as in `windows: click`. | `100` |
|
|
191
|
-
| `deltaX` | `number` | no | The amount of horizontal wheel movement measured in wheel clicks. Positive = right, Negative = left. | `-5` |
|
|
192
|
-
| `deltaY` | `number` | no | The amount of vertical wheel movement. Positive = forward (away), Negative = backward (toward). | `5` |
|
|
193
|
-
| `modifierKeys` | `string[]` \| `string` | no | Same as in `windows: click`. | `win` |
|
|
194
|
-
|
|
195
|
-
#### Usage
|
|
196
|
-
```python
|
|
197
|
-
driver.execute_script('windows: scroll', {
|
|
198
|
-
'elementId': element.id,
|
|
199
|
-
'deltaY': -5, # Scroll down 5 clicks
|
|
200
|
-
'modifierKeys': 'shift'
|
|
201
|
-
})
|
|
202
|
-
```
|
|
203
|
-
|
|
204
|
-
#### `windows: hover`
|
|
205
|
-
This is a shortcut for a hover gesture.
|
|
206
|
-
|
|
207
|
-
| Name | Type | Required | Description | Example |
|
|
208
|
-
| :--- | :--- | :--- | :--- | :--- |
|
|
209
|
-
| `startElementId` | `string` | no | Same as in `windows: click`. | `123e4567-e89b...` |
|
|
210
|
-
| `startX` | `number` | no | Same as in `windows: click`. | `100` |
|
|
211
|
-
| `startY` | `number` | no | Same as in `windows: click`. | `100` |
|
|
212
|
-
| `endElementId` | `string` | no | Same as in `windows: click`. | `123e4567-e89b...` |
|
|
213
|
-
| `endX` | `number` | no | Same as in `windows: click`. | `200` |
|
|
214
|
-
| `endY` | `number` | no | Same as in `windows: click`. | `200` |
|
|
215
|
-
| `modifierKeys` | `string[]` \| `string` | no | Same as in `windows: click`. | `shift` |
|
|
216
|
-
| `durationMs` | `number` | no | The number of milliseconds between moving the cursor from the starting to the ending hover point. 500ms by default. | `700` |
|
|
217
|
-
|
|
218
|
-
#### Usage
|
|
219
|
-
```python
|
|
220
|
-
driver.execute_script('windows: hover', {
|
|
221
|
-
'startElementId': element1.id,
|
|
222
|
-
'endElementId': element2.id,
|
|
223
|
-
'durationMs': 1000
|
|
224
|
-
})
|
|
225
|
-
```
|
|
226
|
-
|
|
227
|
-
### Keyboard
|
|
228
|
-
|
|
229
|
-
#### `windows: typeDelay`
|
|
230
|
-
Sets the delay between key injections in milliseconds. This persistent setting applies to the entire session until changed.
|
|
231
|
-
|
|
232
|
-
| Name | Type | Required | Description | Example |
|
|
233
|
-
| :--- | :--- | :--- | :--- | :--- |
|
|
234
|
-
| `delay` | `number` | yes | Delay in milliseconds. | `100` |
|
|
235
|
-
|
|
236
|
-
#### Usage
|
|
237
|
-
```python
|
|
238
|
-
driver.execute_script('windows: typeDelay', {'delay': 500})
|
|
239
|
-
# or shorthand
|
|
240
|
-
driver.execute_script('windows: typeDelay', '500')
|
|
241
|
-
```
|
|
242
|
-
|
|
243
|
-
#### `windows: keys`
|
|
244
|
-
This is a shortcut for a customized keyboard input. Selenium keys should also work as modifier keys.
|
|
245
|
-
|
|
246
|
-
| Name | Type | Required | Description | Example |
|
|
247
|
-
| :--- | :--- | :--- | :--- | :--- |
|
|
248
|
-
| `actions` | `KeyAction[]` \| `KeyAction` | yes | One or more KeyAction dictionaries. | `[{'virtualKeyCode': 0x10, 'down': true}]` |
|
|
249
|
-
| `forceUnicode` | `boolean` | no | Forces the characters to be sent as unicode characters. | `true` |
|
|
250
|
-
|
|
251
|
-
##### KeyAction Dictionary
|
|
252
|
-
|
|
253
|
-
| Name | Type | Required | Description | Example |
|
|
254
|
-
| :--- | :--- | :--- | :--- | :--- |
|
|
255
|
-
| `pause` | `number` | no | Allows to set a delay in milliseconds between key input series. | `100` |
|
|
256
|
-
| `text` | `string` | no | Non-empty string of Unicode text to type. | `Hello` |
|
|
257
|
-
| `virtualKeyCode` | `number` | no | Valid virtual key code. | `0x10` |
|
|
258
|
-
| `down` | `boolean` | no | If set to `true` then the corresponding key will be depressed, `false` - released. | `true` |
|
|
259
|
-
|
|
260
|
-
#### Usage
|
|
261
|
-
```python
|
|
262
|
-
driver.execute_script('windows: keys', {
|
|
263
|
-
'actions': [
|
|
264
|
-
{'virtualKeyCode': 0x10, 'down': True}, # Shift Down
|
|
265
|
-
{'text': 'Hello World'},
|
|
266
|
-
{'virtualKeyCode': 0x10, 'down': False} # Shift Up
|
|
267
|
-
]
|
|
268
|
-
})
|
|
269
|
-
```
|
|
270
|
-
|
|
271
|
-
### System & State
|
|
272
|
-
|
|
273
|
-
#### `windows: setClipboard`
|
|
274
|
-
Sets Windows clipboard content to the given text or a PNG image.
|
|
275
|
-
|
|
276
|
-
| Name | Type | Required | Description | Example |
|
|
277
|
-
| :--- | :--- | :--- | :--- | :--- |
|
|
278
|
-
| `b64Content` | `string` | yes | Base64-encoded content of the clipboard to be set. | `QXBwaXVt` |
|
|
279
|
-
| `contentType` | `string` | no | Set to `plaintext` (default) or `image`. | `image` |
|
|
280
|
-
|
|
281
|
-
#### Usage
|
|
282
|
-
```python
|
|
283
|
-
driver.execute_script('windows: setClipboard', {
|
|
284
|
-
'b64Content': 'SGVsbG8=', # "Hello" in Base64
|
|
285
|
-
'contentType': 'plaintext'
|
|
286
|
-
})
|
|
287
|
-
```
|
|
288
|
-
|
|
289
|
-
#### `windows: getClipboard`
|
|
290
|
-
Retrieves Windows clipboard content.
|
|
291
|
-
|
|
292
|
-
| Name | Type | Required | Description | Example |
|
|
293
|
-
| :--- | :--- | :--- | :--- | :--- |
|
|
294
|
-
| `contentType` | `string` | no | Set to `plaintext` (default) or `image`. | `image` |
|
|
295
|
-
|
|
296
|
-
#### Usage
|
|
297
|
-
```python
|
|
298
|
-
content = driver.execute_script('windows: getClipboard', {
|
|
299
|
-
'contentType': 'plaintext'
|
|
300
|
-
})
|
|
301
|
-
print(content)
|
|
302
|
-
```
|
|
303
|
-
|
|
304
|
-
#### `windows: pushCacheRequest`
|
|
305
|
-
This is an asynchronous function that sends cache requests based on specific conditions.
|
|
306
|
-
|
|
307
|
-
| Name | Type | Required | Description | Example |
|
|
308
|
-
| :--- | :--- | :--- | :--- | :--- |
|
|
309
|
-
| `treeFilter` | `string` | yes | Defines the filter that is applied when walking the automation tree. | `RawView` |
|
|
310
|
-
| `treeScope` | `string` | no | Defines the scope of the automation tree to be cached. | `SubTree` |
|
|
311
|
-
| `automationElementMode` | `string` | no | Specifies the mode of automation element (e.g., `None`, `Full`). | `Full` |
|
|
312
|
-
|
|
313
|
-
#### Usage
|
|
314
|
-
```python
|
|
315
|
-
driver.execute_script('windows: pushCacheRequest', {
|
|
316
|
-
'treeFilter': 'RawView',
|
|
317
|
-
'treeScope': 'SubTree'
|
|
318
|
-
})
|
|
319
|
-
```
|
|
320
|
-
|
|
321
|
-
### Element Operations
|
|
322
|
-
|
|
323
|
-
#### `windows: invoke`
|
|
324
|
-
Invokes a UI element pattern, simulating an interaction like clicking or activating the element.
|
|
325
|
-
|
|
326
|
-
| Position | Type | Description | Example |
|
|
327
|
-
| :--- | :--- | :--- | :--- |
|
|
328
|
-
| 1 | `Element` | The UI element on which the `InvokePattern` is called. | `element` |
|
|
329
|
-
|
|
330
|
-
#### Usage
|
|
331
|
-
```python
|
|
332
|
-
driver.execute_script('windows: invoke', element)
|
|
333
|
-
```
|
|
334
|
-
|
|
335
|
-
#### `windows: expand`
|
|
336
|
-
Expands a UI element that supports the `ExpandPattern`.
|
|
337
|
-
|
|
338
|
-
| Position | Type | Description | Example |
|
|
339
|
-
| :--- | :--- | :--- | :--- |
|
|
340
|
-
| 1 | `Element` | The UI element to expand. | `element` |
|
|
341
|
-
|
|
342
|
-
#### Usage
|
|
343
|
-
```python
|
|
344
|
-
driver.execute_script('windows: expand', element)
|
|
345
|
-
```
|
|
346
|
-
|
|
347
|
-
#### `windows: collapse`
|
|
348
|
-
Collapses a UI element that supports the `CollapsePattern`.
|
|
349
|
-
|
|
350
|
-
| Position | Type | Description | Example |
|
|
351
|
-
| :--- | :--- | :--- | :--- |
|
|
352
|
-
| 1 | `Element` | The UI element to collapse. | `element` |
|
|
353
|
-
|
|
354
|
-
#### Usage
|
|
355
|
-
```python
|
|
356
|
-
driver.execute_script('windows: collapse', element)
|
|
357
|
-
```
|
|
358
|
-
|
|
359
|
-
#### `windows: setValue`
|
|
360
|
-
Sets the value of a UI element using the `ValuePattern`.
|
|
361
|
-
|
|
362
|
-
| Position | Type | Description | Example |
|
|
363
|
-
| :--- | :--- | :--- | :--- |
|
|
364
|
-
| 1 | `Element` | The UI element whose value will be set. | `element` |
|
|
365
|
-
| 2 | `string` | The value to be set. | `"new value"` |
|
|
366
|
-
|
|
367
|
-
#### Usage
|
|
368
|
-
```python
|
|
369
|
-
driver.execute_script('windows: setValue', element, 'New Value')
|
|
370
|
-
```
|
|
371
|
-
|
|
372
|
-
#### `windows: getValue`
|
|
373
|
-
Gets the current value of a UI element that supports the `ValuePattern`.
|
|
374
|
-
|
|
375
|
-
| Position | Type | Description | Example |
|
|
376
|
-
| :--- | :--- | :--- | :--- |
|
|
377
|
-
| 1 | `Element` | The UI element from which to retrieve the value. | `element` |
|
|
378
|
-
|
|
379
|
-
#### Usage
|
|
380
|
-
```python
|
|
381
|
-
value = driver.execute_script('windows: getValue', element)
|
|
382
|
-
```
|
|
383
|
-
|
|
384
|
-
#### `windows: scrollIntoView`
|
|
385
|
-
Scrolls the UI element into view using the `ScrollItemPattern`.
|
|
386
|
-
|
|
387
|
-
| Position | Type | Description | Example |
|
|
388
|
-
| :--- | :--- | :--- | :--- |
|
|
389
|
-
| 1 | `Element` | The UI element to bring into view. | `element` |
|
|
390
|
-
|
|
391
|
-
#### Usage
|
|
392
|
-
```python
|
|
393
|
-
driver.execute_script('windows: scrollIntoView', element)
|
|
394
|
-
```
|
|
395
|
-
|
|
396
|
-
#### `windows: toggle`
|
|
397
|
-
Toggles a UI element’s state using the `TogglePattern`.
|
|
398
|
-
|
|
399
|
-
| Position | Type | Description | Example |
|
|
400
|
-
| :--- | :--- | :--- | :--- |
|
|
401
|
-
| 1 | `Element` | The UI element to toggle. | `element` |
|
|
402
|
-
|
|
403
|
-
#### Usage
|
|
404
|
-
```python
|
|
405
|
-
driver.execute_script('windows: toggle', element)
|
|
406
|
-
```
|
|
407
|
-
|
|
408
|
-
### Selection Management
|
|
409
|
-
|
|
410
|
-
#### `windows: select`
|
|
411
|
-
Selects a UI element using the `SelectionPattern`.
|
|
412
|
-
|
|
413
|
-
| Position | Type | Description | Example |
|
|
414
|
-
| :--- | :--- | :--- | :--- |
|
|
415
|
-
| 1 | `Element` | The UI element to select. | `element` |
|
|
416
|
-
|
|
417
|
-
#### Usage
|
|
418
|
-
```python
|
|
419
|
-
driver.execute_script('windows: select', element)
|
|
420
|
-
```
|
|
421
|
-
|
|
422
|
-
#### `windows: addToSelection`
|
|
423
|
-
Adds an element to the current selection on a UI element that supports the `SelectionPattern`.
|
|
424
|
-
|
|
425
|
-
| Position | Type | Description | Example |
|
|
426
|
-
| :--- | :--- | :--- | :--- |
|
|
427
|
-
| 1 | `Element` | The UI element to add to the selection. | `element` |
|
|
428
|
-
|
|
429
|
-
#### Usage
|
|
430
|
-
```python
|
|
431
|
-
driver.execute_script('windows: addToSelection', element)
|
|
432
|
-
```
|
|
433
|
-
|
|
434
|
-
#### `windows: removeFromSelection`
|
|
435
|
-
Removes an element from the current selection on a UI element that supports the `SelectionPattern`.
|
|
436
|
-
|
|
437
|
-
| Position | Type | Description | Example |
|
|
438
|
-
| :--- | :--- | :--- | :--- |
|
|
439
|
-
| 1 | `Element` | The UI element to remove from the selection. | `element` |
|
|
440
|
-
|
|
441
|
-
#### Usage
|
|
442
|
-
```python
|
|
443
|
-
driver.execute_script('windows: removeFromSelection', element)
|
|
444
|
-
```
|
|
445
|
-
|
|
446
|
-
#### `windows: isMultiple`
|
|
447
|
-
Checks if a UI element supports multiple selection using the `SelectionPattern`.
|
|
448
|
-
|
|
449
|
-
| Position | Type | Description | Example |
|
|
450
|
-
| :--- | :--- | :--- | :--- |
|
|
451
|
-
| 1 | `Element` | The UI element to check. | `element` |
|
|
452
|
-
|
|
453
|
-
#### Usage
|
|
454
|
-
```python
|
|
455
|
-
is_multi = driver.execute_script('windows: isMultiple', element)
|
|
456
|
-
```
|
|
457
|
-
|
|
458
|
-
#### `windows: selectedItem`
|
|
459
|
-
Gets the selected item from a UI element that supports the `SelectionPattern`.
|
|
460
|
-
|
|
461
|
-
| Position | Type | Description | Example |
|
|
462
|
-
| :--- | :--- | :--- | :--- |
|
|
463
|
-
| 1 | `Element` | The UI element from which to retrieve the selected item. | `element` |
|
|
464
|
-
|
|
465
|
-
#### Usage
|
|
466
|
-
```python
|
|
467
|
-
selected_el = driver.execute_script('windows: selectedItem', element)
|
|
468
|
-
```
|
|
469
|
-
|
|
470
|
-
#### `windows: allSelectedItems`
|
|
471
|
-
Gets all selected items from a UI element that supports the `SelectionPattern`.
|
|
472
|
-
|
|
473
|
-
| Position | Type | Description | Example |
|
|
474
|
-
| :--- | :--- | :--- | :--- |
|
|
475
|
-
| 1 | `Element` | The UI element from which to retrieve all selected items. | `element` |
|
|
476
|
-
|
|
477
|
-
#### Usage
|
|
478
|
-
```python
|
|
479
|
-
selected_els = driver.execute_script('windows: allSelectedItems', element)
|
|
480
|
-
```
|
|
481
|
-
|
|
482
|
-
### Window Management
|
|
483
|
-
|
|
484
|
-
#### `windows: maximize`
|
|
485
|
-
Maximizes a window or UI element using the `WindowPattern`.
|
|
486
|
-
|
|
487
|
-
| Position | Type | Description | Example |
|
|
488
|
-
| :--- | :--- | :--- | :--- |
|
|
489
|
-
| 1 | `Element` | The window or UI element to maximize. | `element` |
|
|
490
|
-
|
|
491
|
-
#### Usage
|
|
492
|
-
```python
|
|
493
|
-
driver.execute_script('windows: maximize', element)
|
|
494
|
-
```
|
|
495
|
-
|
|
496
|
-
#### `windows: minimize`
|
|
497
|
-
Minimizes a window or UI element using the `WindowPattern`.
|
|
498
|
-
|
|
499
|
-
| Position | Type | Description | Example |
|
|
500
|
-
| :--- | :--- | :--- | :--- |
|
|
501
|
-
| 1 | `Element` | The window or UI element to minimize. | `element` |
|
|
502
|
-
|
|
503
|
-
#### Usage
|
|
504
|
-
```python
|
|
505
|
-
driver.execute_script('windows: minimize', element)
|
|
506
|
-
```
|
|
507
|
-
|
|
508
|
-
#### `windows: restore`
|
|
509
|
-
Restores a window or UI element to its normal state using the `WindowPattern`.
|
|
510
|
-
|
|
511
|
-
| Position | Type | Description | Example |
|
|
512
|
-
| :--- | :--- | :--- | :--- |
|
|
513
|
-
| 1 | `Element` | The window or UI element to restore. | `element` |
|
|
514
|
-
|
|
515
|
-
#### Usage
|
|
516
|
-
```python
|
|
517
|
-
driver.execute_script('windows: restore', element)
|
|
518
|
-
```
|
|
519
|
-
|
|
520
|
-
#### `windows: close`
|
|
521
|
-
Closes a window or UI element using the `WindowPattern`.
|
|
522
|
-
|
|
523
|
-
| Position | Type | Description | Example |
|
|
524
|
-
| :--- | :--- | :--- | :--- |
|
|
525
|
-
| 1 | `Element` | The window or UI element to close. | `element` |
|
|
526
|
-
|
|
527
|
-
#### Usage
|
|
528
|
-
```python
|
|
529
|
-
driver.execute_script('windows: close', element)
|
|
530
|
-
```
|
|
531
|
-
|
|
532
|
-
#### `windows: setFocus`
|
|
533
|
-
Sets focus to the specified UI element using UIAutomationElement's `SetFocus` method.
|
|
534
|
-
|
|
535
|
-
| Position | Type | Description | Example |
|
|
536
|
-
| :--- | :--- | :--- | :--- |
|
|
537
|
-
| 1 | `Element` | The UI element to set focus on. | `element` |
|
|
538
|
-
|
|
539
|
-
#### Usage
|
|
540
|
-
```python
|
|
541
|
-
driver.execute_script('windows: setFocus', element)
|
|
542
|
-
```
|
|
543
|
-
|
|
544
|
-
---
|
|
545
|
-
|
|
546
|
-
## 🛠 Development
|
|
547
|
-
|
|
548
|
-
Recommended VS Code plugin: [Comment tagged templates](https://marketplace.visualstudio.com/items?itemName=bierner.comment-tagged-templates) for syntax highlighting.
|
|
549
|
-
|
|
550
|
-
```bash
|
|
551
|
-
npm install # Setup dependencies
|
|
552
|
-
npm run lint # Code quality check
|
|
553
|
-
npm run build # Transpile TypeScript to JS
|
|
554
|
-
```
|
|
1
|
+
NovaWindows2 Driver
|
|
2
|
+
===================
|
|
3
|
+
|
|
4
|
+
NovaWindows2 Driver is a custom Appium driver designed to tackle the limitations of existing Windows automation solutions like WinAppDriver. It supports testing Universal Windows Platform (UWP), Windows Forms (WinForms), Windows Presentation Foundation (WPF), and Classic Windows (Win32) apps on Windows 10 and later.
|
|
5
|
+
|
|
6
|
+
Built to improve performance and reliability for traditional desktop applications, it offers:
|
|
7
|
+
- **Faster XPath locator performance** — Reduces element lookup times, even in complex UIs.
|
|
8
|
+
- **RawView element support** — Access elements typically hidden from the default ControlView/ContentView.
|
|
9
|
+
- **Enhanced text input handling** — Fast text entry with support for various keyboard layouts.
|
|
10
|
+
- **Platform-specific commands** — Supports direct window manipulation, advanced UI interactions, and more.
|
|
11
|
+
- **Seamless Setup** — Designed to work without Developer Mode or additional software.
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## 📑 Table of Contents
|
|
16
|
+
- [Getting Started](#-getting-started)
|
|
17
|
+
- [Configuration](#-configuration)
|
|
18
|
+
- [Example Usage](#-example-usage)
|
|
19
|
+
- [Key Features](#-key-features)
|
|
20
|
+
- [Element Location](#element-location)
|
|
21
|
+
- [Attribute Retrieval](#attribute-retrieval)
|
|
22
|
+
- [PowerShell Execution](#powershell-execution)
|
|
23
|
+
- [Platform-Specific Extensions](#-platform-specific-extensions)
|
|
24
|
+
- [Mouse & Pointer](#mouse--pointer)
|
|
25
|
+
- [Keyboard](#keyboard)
|
|
26
|
+
- [Element Operations](#element-operations)
|
|
27
|
+
- [Selection Management](#selection-management)
|
|
28
|
+
- [Window Management](#window-management)
|
|
29
|
+
- [System & State](#system--state)
|
|
30
|
+
- [Development](#-development)
|
|
31
|
+
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
## 🚀 Getting Started
|
|
35
|
+
|
|
36
|
+
### Installation
|
|
37
|
+
The driver is built for Appium 3. To install it, run:
|
|
38
|
+
```bash
|
|
39
|
+
appium driver install --source=npm appium-novawindows2-driver
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### Prerequisites
|
|
43
|
+
- **Host OS**: Windows 10 or later.
|
|
44
|
+
- No Developer Mode or extra dependencies required.
|
|
45
|
+
|
|
46
|
+
---
|
|
47
|
+
|
|
48
|
+
## ⚙️ Configuration
|
|
49
|
+
|
|
50
|
+
NovaWindows2 Driver supports the following capabilities:
|
|
51
|
+
|
|
52
|
+
| Capability Name | Description | Default | Example |
|
|
53
|
+
| :--- | :--- | :--- | :--- |
|
|
54
|
+
| `platformName` | Must be set to `Windows` (case-insensitive). | (Required) | `Windows` |
|
|
55
|
+
| `automationName` | Must be set to `NovaWindows2` (case-insensitive). | (Required) | `NovaWindows2` |
|
|
56
|
+
| `smoothPointerMove` | CSS-like easing function (including valid Bezier curve). This controls the smooth movement of the mouse for `delayBeforeClick` ms. | (None) | `ease-in`, `cubic-bezier(0.42, 0, 0.58, 1)` |
|
|
57
|
+
| `delayBeforeClick` | Time in milliseconds before a click is performed. | `0` | `500` |
|
|
58
|
+
| `delayAfterClick` | Time in milliseconds after a click is performed. | `0` | `500` |
|
|
59
|
+
| `appTopLevelWindow` | The handle of an existing application top-level window to attach to. It can be a number or string (not necessarily hexadecimal). | (None) | `12345`, `0x12345` |
|
|
60
|
+
| `shouldCloseApp` | Whether to close the window of the application in test after the session finishes. | `true` | `false` |
|
|
61
|
+
| `appArguments` | Optional string of arguments to pass to the app on launch. | (None) | `--debug` |
|
|
62
|
+
| `appWorkingDir` | Optional working directory path for the application. | (None) | `C:\Temp` |
|
|
63
|
+
| `prerun` | An object containing either `script` or `command` key. The value of each key must be a valid PowerShell script or command to be executed prior to the WinAppDriver session startup. See [Power Shell commands execution](#powershell-execution) for more details. | (None) | `{script: 'Get-Process outlook -ErrorAction SilentlyContinue'}` |
|
|
64
|
+
| `postrun` | An object containing either `script` or `command` key. The value of each key must be a valid PowerShell script or command to be executed after WinAppDriver session is stopped. See [Power Shell commands execution](#powershell-execution) for more details. | (None) | `{command: '...'}` |
|
|
65
|
+
| `isolatedScriptExecution` | Whether PowerShell scripts are executed in an isolated session. | `false` | `true` |
|
|
66
|
+
| `appWaitForLaunchRetries` | Number of retries when waiting for the app to launch. | `20` | `5` |
|
|
67
|
+
| `appWaitForLaunchRetryIntervalMs` | Interval (ms) between app launch check retries. | `500` | `500` |
|
|
68
|
+
| `powerShellCommandTimeout` | Timeout (ms) for PowerShell script execution. | `60000` | `30000` |
|
|
69
|
+
| `convertAbsoluteXPathToRelativeFromElement` | Convert absolute XPath to relative when searching from an element. | `true` | `true` |
|
|
70
|
+
| `includeContextElementInSearch` | Include the context element itself in the search. | `true` | `true` |
|
|
71
|
+
| `releaseModifierKeys` | Whether to release modifier keys after `sendKeys`. | `true` | `true` |
|
|
72
|
+
| `typeDelay` | Time in milliseconds to wait after inputting each character. Note that this delay does not apply to modifier keys (Shift, Ctrl, Alt, Win). | `0` | `100` |
|
|
73
|
+
|
|
74
|
+
---
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
## 💡 Example Usage
|
|
79
|
+
|
|
80
|
+
Check out the [examples/refactor](examples/refactor) directory for comprehensive examples.
|
|
81
|
+
|
|
82
|
+
### Python (Appium-Python-Client)
|
|
83
|
+
```python
|
|
84
|
+
from appium import webdriver
|
|
85
|
+
from appium.options.windows import WindowsOptions
|
|
86
|
+
|
|
87
|
+
options = WindowsOptions()
|
|
88
|
+
options.app = 'C:\\Windows\\System32\\notepad.exe'
|
|
89
|
+
options.automation_name = 'NovaWindows2'
|
|
90
|
+
|
|
91
|
+
driver = webdriver.Remote('http://127.0.0.1:4723', options=options)
|
|
92
|
+
# ... tests ...
|
|
93
|
+
driver.quit()
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
---
|
|
97
|
+
|
|
98
|
+
## ✨ Key Features
|
|
99
|
+
|
|
100
|
+
### Element Location
|
|
101
|
+
Appium Windows Driver supports the same location strategies [the WinAppDriver supports](https://github.com/microsoft/WinAppDriver/blob/master/Docs/AuthoringTestScripts.md#supported-locators-to-find-ui-elements), but also includes Windows UIAutomation conditions:
|
|
102
|
+
|
|
103
|
+
| Name | Description | Example |
|
|
104
|
+
| :--- | :--- | :--- |
|
|
105
|
+
| `accessibility id` | This strategy is `AutomationId` attribute in inspect.exe | `CalculatorResults` |
|
|
106
|
+
| `class name` | This strategy is `ClassName` attribute in inspect.exe | `TextBlock` |
|
|
107
|
+
| `id` | This strategy is `RuntimeId` (decimal) attribute in inspect.exe | `42.333896.3.1` |
|
|
108
|
+
| `name` | This strategy is `Name` attribute in inspect.exe | `Calculator` |
|
|
109
|
+
| `tag name` | This strategy is `LocalizedControlType` (upper camel case) attribute in inspect.exe | `Text` |
|
|
110
|
+
| `xpath` | Custom XPath 1.0 queries on any attribute exposed by inspect.exe. | `(//Button)[2]` |
|
|
111
|
+
| `windows uiautomation` | UIAutomation conditions (C# or PowerShell syntax). | `new PropertyCondition(...)` |
|
|
112
|
+
|
|
113
|
+
### Attribute Retrieval
|
|
114
|
+
Retrieve comprehensive details about UI elements using standard or bulk methods.
|
|
115
|
+
|
|
116
|
+
- **Bulk Retrieval**: Use the `"all"` keyword to get 80+ properties in a single JSON object.
|
|
117
|
+
- **Dotted Names**: Access pattern-specific properties directly (e.g., `Window.CanMaximize`, `LegacyIAccessible.Name`).
|
|
118
|
+
|
|
119
|
+
```js
|
|
120
|
+
// getAttributes returns all properties as a JSON string
|
|
121
|
+
const allAttributes = await element.getAttribute("all");
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
### PowerShell Execution
|
|
125
|
+
Execute internal PowerShell scripts or commands directly from your test. This requires the `power_shell` insecure feature to be enabled on the Appium server.
|
|
126
|
+
|
|
127
|
+
It is possible to execute a single PowerShell command or a whole script. Note that `powerShell` is case-insensitive.
|
|
128
|
+
|
|
129
|
+
```javascript
|
|
130
|
+
// Execute a command string
|
|
131
|
+
await driver.executeScript('powerShell', { command: 'Get-Process Notepad' });
|
|
132
|
+
|
|
133
|
+
// Execute a script string
|
|
134
|
+
await driver.executeScript('powerShell', { script: '$p = Get-Process Notepad; $p.Kill();' });
|
|
135
|
+
|
|
136
|
+
// Shorthand (executes as command/script depending on context)
|
|
137
|
+
await driver.executeScript('powerShell', 'Get-Process');
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
### Enhanced Text Input
|
|
141
|
+
You can specify the delay directly within the text string using the `[delay:ms]` pattern. This overrides the session setting (set via `windows: typeDelay` or `typeDelay` capability) for that specific action.
|
|
142
|
+
|
|
143
|
+
```python
|
|
144
|
+
driver.find_element(...).send_keys("[delay:500]Slow text")
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
---
|
|
148
|
+
|
|
149
|
+
## 🛠 Platform-Specific Extensions
|
|
150
|
+
|
|
151
|
+
All extensions are invoked via `driver.executeScript("windows: <methodName>", ...args)`.
|
|
152
|
+
Below are the detailed descriptions and arguments for each command.
|
|
153
|
+
|
|
154
|
+
> **Note**
|
|
155
|
+
> In most cases, commands can be used more intuitively by passing the element as the first argument (if required) and other parameters subsequently.
|
|
156
|
+
|
|
157
|
+
### Mouse & Pointer
|
|
158
|
+
|
|
159
|
+
#### `windows: click`
|
|
160
|
+
This is a shortcut for a single mouse click gesture.
|
|
161
|
+
|
|
162
|
+
| Name | Type | Required | Description | Example |
|
|
163
|
+
| :--- | :--- | :--- | :--- | :--- |
|
|
164
|
+
| `elementId` | `string` | no | Hexadecimal identifier of the element to click on. If this parameter is missing then given coordinates will be parsed as absolute ones. Otherwise they are parsed as relative to the top left corner of this element. | `123e4567-e89b...` |
|
|
165
|
+
| `x` | `number` | no | Integer horizontal coordinate of the click point. Both x and y coordinates must be provided or none of them if elementId is present. | `100` |
|
|
166
|
+
| `y` | `number` | no | Integer vertical coordinate of the click point. Both x and y coordinates must be provided or none of them if elementId is present. | `100` |
|
|
167
|
+
| `button` | `string` | no | Name of the mouse button to be clicked. Supported button names are: `left`, `middle`, `right`, `back`, `forward`. The default value is `left`. | `right` |
|
|
168
|
+
| `modifierKeys` | `string[]` \| `string` | no | List of possible keys or a single key name to depress while the click is being performed. Supported key names are: `Shift`, `Ctrl`, `Alt`, `Win`. | `['ctrl', 'alt']` |
|
|
169
|
+
| `durationMs` | `number` | no | The number of milliseconds to wait between pressing and releasing the mouse button. By default no delay is applied. | `500` |
|
|
170
|
+
| `times` | `number` | no | How many times the click must be performed. One by default. | `2` |
|
|
171
|
+
| `interClickDelayMs` | `number` | no | Duration of the pause between each click gesture. Only makes sense if `times` is greater than one. 100ms by default. | `10` |
|
|
172
|
+
|
|
173
|
+
#### Usage
|
|
174
|
+
```python
|
|
175
|
+
driver.execute_script('windows: click', {
|
|
176
|
+
'elementId': element.id,
|
|
177
|
+
'button': 'right',
|
|
178
|
+
'times': 2,
|
|
179
|
+
'modifierKeys': ['ctrl', 'alt']
|
|
180
|
+
})
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
#### `windows: scroll`
|
|
184
|
+
This is a shortcut for a mouse wheel scroll gesture. The API is a thin wrapper over the SendInput WinApi call.
|
|
185
|
+
|
|
186
|
+
| Name | Type | Required | Description | Example |
|
|
187
|
+
| :--- | :--- | :--- | :--- | :--- |
|
|
188
|
+
| `elementId` | `string` | no | Same as in `windows: click`. | `123e4567-e89b...` |
|
|
189
|
+
| `x` | `number` | no | Same as in `windows: click`. | `100` |
|
|
190
|
+
| `y` | `number` | no | Same as in `windows: click`. | `100` |
|
|
191
|
+
| `deltaX` | `number` | no | The amount of horizontal wheel movement measured in wheel clicks. Positive = right, Negative = left. | `-5` |
|
|
192
|
+
| `deltaY` | `number` | no | The amount of vertical wheel movement. Positive = forward (away), Negative = backward (toward). | `5` |
|
|
193
|
+
| `modifierKeys` | `string[]` \| `string` | no | Same as in `windows: click`. | `win` |
|
|
194
|
+
|
|
195
|
+
#### Usage
|
|
196
|
+
```python
|
|
197
|
+
driver.execute_script('windows: scroll', {
|
|
198
|
+
'elementId': element.id,
|
|
199
|
+
'deltaY': -5, # Scroll down 5 clicks
|
|
200
|
+
'modifierKeys': 'shift'
|
|
201
|
+
})
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
#### `windows: hover`
|
|
205
|
+
This is a shortcut for a hover gesture.
|
|
206
|
+
|
|
207
|
+
| Name | Type | Required | Description | Example |
|
|
208
|
+
| :--- | :--- | :--- | :--- | :--- |
|
|
209
|
+
| `startElementId` | `string` | no | Same as in `windows: click`. | `123e4567-e89b...` |
|
|
210
|
+
| `startX` | `number` | no | Same as in `windows: click`. | `100` |
|
|
211
|
+
| `startY` | `number` | no | Same as in `windows: click`. | `100` |
|
|
212
|
+
| `endElementId` | `string` | no | Same as in `windows: click`. | `123e4567-e89b...` |
|
|
213
|
+
| `endX` | `number` | no | Same as in `windows: click`. | `200` |
|
|
214
|
+
| `endY` | `number` | no | Same as in `windows: click`. | `200` |
|
|
215
|
+
| `modifierKeys` | `string[]` \| `string` | no | Same as in `windows: click`. | `shift` |
|
|
216
|
+
| `durationMs` | `number` | no | The number of milliseconds between moving the cursor from the starting to the ending hover point. 500ms by default. | `700` |
|
|
217
|
+
|
|
218
|
+
#### Usage
|
|
219
|
+
```python
|
|
220
|
+
driver.execute_script('windows: hover', {
|
|
221
|
+
'startElementId': element1.id,
|
|
222
|
+
'endElementId': element2.id,
|
|
223
|
+
'durationMs': 1000
|
|
224
|
+
})
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
### Keyboard
|
|
228
|
+
|
|
229
|
+
#### `windows: typeDelay`
|
|
230
|
+
Sets the delay between key injections in milliseconds. This persistent setting applies to the entire session until changed.
|
|
231
|
+
|
|
232
|
+
| Name | Type | Required | Description | Example |
|
|
233
|
+
| :--- | :--- | :--- | :--- | :--- |
|
|
234
|
+
| `delay` | `number` | yes | Delay in milliseconds. | `100` |
|
|
235
|
+
|
|
236
|
+
#### Usage
|
|
237
|
+
```python
|
|
238
|
+
driver.execute_script('windows: typeDelay', {'delay': 500})
|
|
239
|
+
# or shorthand
|
|
240
|
+
driver.execute_script('windows: typeDelay', '500')
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
#### `windows: keys`
|
|
244
|
+
This is a shortcut for a customized keyboard input. Selenium keys should also work as modifier keys.
|
|
245
|
+
|
|
246
|
+
| Name | Type | Required | Description | Example |
|
|
247
|
+
| :--- | :--- | :--- | :--- | :--- |
|
|
248
|
+
| `actions` | `KeyAction[]` \| `KeyAction` | yes | One or more KeyAction dictionaries. | `[{'virtualKeyCode': 0x10, 'down': true}]` |
|
|
249
|
+
| `forceUnicode` | `boolean` | no | Forces the characters to be sent as unicode characters. | `true` |
|
|
250
|
+
|
|
251
|
+
##### KeyAction Dictionary
|
|
252
|
+
|
|
253
|
+
| Name | Type | Required | Description | Example |
|
|
254
|
+
| :--- | :--- | :--- | :--- | :--- |
|
|
255
|
+
| `pause` | `number` | no | Allows to set a delay in milliseconds between key input series. | `100` |
|
|
256
|
+
| `text` | `string` | no | Non-empty string of Unicode text to type. | `Hello` |
|
|
257
|
+
| `virtualKeyCode` | `number` | no | Valid virtual key code. | `0x10` |
|
|
258
|
+
| `down` | `boolean` | no | If set to `true` then the corresponding key will be depressed, `false` - released. | `true` |
|
|
259
|
+
|
|
260
|
+
#### Usage
|
|
261
|
+
```python
|
|
262
|
+
driver.execute_script('windows: keys', {
|
|
263
|
+
'actions': [
|
|
264
|
+
{'virtualKeyCode': 0x10, 'down': True}, # Shift Down
|
|
265
|
+
{'text': 'Hello World'},
|
|
266
|
+
{'virtualKeyCode': 0x10, 'down': False} # Shift Up
|
|
267
|
+
]
|
|
268
|
+
})
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
### System & State
|
|
272
|
+
|
|
273
|
+
#### `windows: setClipboard`
|
|
274
|
+
Sets Windows clipboard content to the given text or a PNG image.
|
|
275
|
+
|
|
276
|
+
| Name | Type | Required | Description | Example |
|
|
277
|
+
| :--- | :--- | :--- | :--- | :--- |
|
|
278
|
+
| `b64Content` | `string` | yes | Base64-encoded content of the clipboard to be set. | `QXBwaXVt` |
|
|
279
|
+
| `contentType` | `string` | no | Set to `plaintext` (default) or `image`. | `image` |
|
|
280
|
+
|
|
281
|
+
#### Usage
|
|
282
|
+
```python
|
|
283
|
+
driver.execute_script('windows: setClipboard', {
|
|
284
|
+
'b64Content': 'SGVsbG8=', # "Hello" in Base64
|
|
285
|
+
'contentType': 'plaintext'
|
|
286
|
+
})
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
#### `windows: getClipboard`
|
|
290
|
+
Retrieves Windows clipboard content.
|
|
291
|
+
|
|
292
|
+
| Name | Type | Required | Description | Example |
|
|
293
|
+
| :--- | :--- | :--- | :--- | :--- |
|
|
294
|
+
| `contentType` | `string` | no | Set to `plaintext` (default) or `image`. | `image` |
|
|
295
|
+
|
|
296
|
+
#### Usage
|
|
297
|
+
```python
|
|
298
|
+
content = driver.execute_script('windows: getClipboard', {
|
|
299
|
+
'contentType': 'plaintext'
|
|
300
|
+
})
|
|
301
|
+
print(content)
|
|
302
|
+
```
|
|
303
|
+
|
|
304
|
+
#### `windows: pushCacheRequest`
|
|
305
|
+
This is an asynchronous function that sends cache requests based on specific conditions.
|
|
306
|
+
|
|
307
|
+
| Name | Type | Required | Description | Example |
|
|
308
|
+
| :--- | :--- | :--- | :--- | :--- |
|
|
309
|
+
| `treeFilter` | `string` | yes | Defines the filter that is applied when walking the automation tree. | `RawView` |
|
|
310
|
+
| `treeScope` | `string` | no | Defines the scope of the automation tree to be cached. | `SubTree` |
|
|
311
|
+
| `automationElementMode` | `string` | no | Specifies the mode of automation element (e.g., `None`, `Full`). | `Full` |
|
|
312
|
+
|
|
313
|
+
#### Usage
|
|
314
|
+
```python
|
|
315
|
+
driver.execute_script('windows: pushCacheRequest', {
|
|
316
|
+
'treeFilter': 'RawView',
|
|
317
|
+
'treeScope': 'SubTree'
|
|
318
|
+
})
|
|
319
|
+
```
|
|
320
|
+
|
|
321
|
+
### Element Operations
|
|
322
|
+
|
|
323
|
+
#### `windows: invoke`
|
|
324
|
+
Invokes a UI element pattern, simulating an interaction like clicking or activating the element.
|
|
325
|
+
|
|
326
|
+
| Position | Type | Description | Example |
|
|
327
|
+
| :--- | :--- | :--- | :--- |
|
|
328
|
+
| 1 | `Element` | The UI element on which the `InvokePattern` is called. | `element` |
|
|
329
|
+
|
|
330
|
+
#### Usage
|
|
331
|
+
```python
|
|
332
|
+
driver.execute_script('windows: invoke', element)
|
|
333
|
+
```
|
|
334
|
+
|
|
335
|
+
#### `windows: expand`
|
|
336
|
+
Expands a UI element that supports the `ExpandPattern`.
|
|
337
|
+
|
|
338
|
+
| Position | Type | Description | Example |
|
|
339
|
+
| :--- | :--- | :--- | :--- |
|
|
340
|
+
| 1 | `Element` | The UI element to expand. | `element` |
|
|
341
|
+
|
|
342
|
+
#### Usage
|
|
343
|
+
```python
|
|
344
|
+
driver.execute_script('windows: expand', element)
|
|
345
|
+
```
|
|
346
|
+
|
|
347
|
+
#### `windows: collapse`
|
|
348
|
+
Collapses a UI element that supports the `CollapsePattern`.
|
|
349
|
+
|
|
350
|
+
| Position | Type | Description | Example |
|
|
351
|
+
| :--- | :--- | :--- | :--- |
|
|
352
|
+
| 1 | `Element` | The UI element to collapse. | `element` |
|
|
353
|
+
|
|
354
|
+
#### Usage
|
|
355
|
+
```python
|
|
356
|
+
driver.execute_script('windows: collapse', element)
|
|
357
|
+
```
|
|
358
|
+
|
|
359
|
+
#### `windows: setValue`
|
|
360
|
+
Sets the value of a UI element using the `ValuePattern`.
|
|
361
|
+
|
|
362
|
+
| Position | Type | Description | Example |
|
|
363
|
+
| :--- | :--- | :--- | :--- |
|
|
364
|
+
| 1 | `Element` | The UI element whose value will be set. | `element` |
|
|
365
|
+
| 2 | `string` | The value to be set. | `"new value"` |
|
|
366
|
+
|
|
367
|
+
#### Usage
|
|
368
|
+
```python
|
|
369
|
+
driver.execute_script('windows: setValue', element, 'New Value')
|
|
370
|
+
```
|
|
371
|
+
|
|
372
|
+
#### `windows: getValue`
|
|
373
|
+
Gets the current value of a UI element that supports the `ValuePattern`.
|
|
374
|
+
|
|
375
|
+
| Position | Type | Description | Example |
|
|
376
|
+
| :--- | :--- | :--- | :--- |
|
|
377
|
+
| 1 | `Element` | The UI element from which to retrieve the value. | `element` |
|
|
378
|
+
|
|
379
|
+
#### Usage
|
|
380
|
+
```python
|
|
381
|
+
value = driver.execute_script('windows: getValue', element)
|
|
382
|
+
```
|
|
383
|
+
|
|
384
|
+
#### `windows: scrollIntoView`
|
|
385
|
+
Scrolls the UI element into view using the `ScrollItemPattern`.
|
|
386
|
+
|
|
387
|
+
| Position | Type | Description | Example |
|
|
388
|
+
| :--- | :--- | :--- | :--- |
|
|
389
|
+
| 1 | `Element` | The UI element to bring into view. | `element` |
|
|
390
|
+
|
|
391
|
+
#### Usage
|
|
392
|
+
```python
|
|
393
|
+
driver.execute_script('windows: scrollIntoView', element)
|
|
394
|
+
```
|
|
395
|
+
|
|
396
|
+
#### `windows: toggle`
|
|
397
|
+
Toggles a UI element’s state using the `TogglePattern`.
|
|
398
|
+
|
|
399
|
+
| Position | Type | Description | Example |
|
|
400
|
+
| :--- | :--- | :--- | :--- |
|
|
401
|
+
| 1 | `Element` | The UI element to toggle. | `element` |
|
|
402
|
+
|
|
403
|
+
#### Usage
|
|
404
|
+
```python
|
|
405
|
+
driver.execute_script('windows: toggle', element)
|
|
406
|
+
```
|
|
407
|
+
|
|
408
|
+
### Selection Management
|
|
409
|
+
|
|
410
|
+
#### `windows: select`
|
|
411
|
+
Selects a UI element using the `SelectionPattern`.
|
|
412
|
+
|
|
413
|
+
| Position | Type | Description | Example |
|
|
414
|
+
| :--- | :--- | :--- | :--- |
|
|
415
|
+
| 1 | `Element` | The UI element to select. | `element` |
|
|
416
|
+
|
|
417
|
+
#### Usage
|
|
418
|
+
```python
|
|
419
|
+
driver.execute_script('windows: select', element)
|
|
420
|
+
```
|
|
421
|
+
|
|
422
|
+
#### `windows: addToSelection`
|
|
423
|
+
Adds an element to the current selection on a UI element that supports the `SelectionPattern`.
|
|
424
|
+
|
|
425
|
+
| Position | Type | Description | Example |
|
|
426
|
+
| :--- | :--- | :--- | :--- |
|
|
427
|
+
| 1 | `Element` | The UI element to add to the selection. | `element` |
|
|
428
|
+
|
|
429
|
+
#### Usage
|
|
430
|
+
```python
|
|
431
|
+
driver.execute_script('windows: addToSelection', element)
|
|
432
|
+
```
|
|
433
|
+
|
|
434
|
+
#### `windows: removeFromSelection`
|
|
435
|
+
Removes an element from the current selection on a UI element that supports the `SelectionPattern`.
|
|
436
|
+
|
|
437
|
+
| Position | Type | Description | Example |
|
|
438
|
+
| :--- | :--- | :--- | :--- |
|
|
439
|
+
| 1 | `Element` | The UI element to remove from the selection. | `element` |
|
|
440
|
+
|
|
441
|
+
#### Usage
|
|
442
|
+
```python
|
|
443
|
+
driver.execute_script('windows: removeFromSelection', element)
|
|
444
|
+
```
|
|
445
|
+
|
|
446
|
+
#### `windows: isMultiple`
|
|
447
|
+
Checks if a UI element supports multiple selection using the `SelectionPattern`.
|
|
448
|
+
|
|
449
|
+
| Position | Type | Description | Example |
|
|
450
|
+
| :--- | :--- | :--- | :--- |
|
|
451
|
+
| 1 | `Element` | The UI element to check. | `element` |
|
|
452
|
+
|
|
453
|
+
#### Usage
|
|
454
|
+
```python
|
|
455
|
+
is_multi = driver.execute_script('windows: isMultiple', element)
|
|
456
|
+
```
|
|
457
|
+
|
|
458
|
+
#### `windows: selectedItem`
|
|
459
|
+
Gets the selected item from a UI element that supports the `SelectionPattern`.
|
|
460
|
+
|
|
461
|
+
| Position | Type | Description | Example |
|
|
462
|
+
| :--- | :--- | :--- | :--- |
|
|
463
|
+
| 1 | `Element` | The UI element from which to retrieve the selected item. | `element` |
|
|
464
|
+
|
|
465
|
+
#### Usage
|
|
466
|
+
```python
|
|
467
|
+
selected_el = driver.execute_script('windows: selectedItem', element)
|
|
468
|
+
```
|
|
469
|
+
|
|
470
|
+
#### `windows: allSelectedItems`
|
|
471
|
+
Gets all selected items from a UI element that supports the `SelectionPattern`.
|
|
472
|
+
|
|
473
|
+
| Position | Type | Description | Example |
|
|
474
|
+
| :--- | :--- | :--- | :--- |
|
|
475
|
+
| 1 | `Element` | The UI element from which to retrieve all selected items. | `element` |
|
|
476
|
+
|
|
477
|
+
#### Usage
|
|
478
|
+
```python
|
|
479
|
+
selected_els = driver.execute_script('windows: allSelectedItems', element)
|
|
480
|
+
```
|
|
481
|
+
|
|
482
|
+
### Window Management
|
|
483
|
+
|
|
484
|
+
#### `windows: maximize`
|
|
485
|
+
Maximizes a window or UI element using the `WindowPattern`.
|
|
486
|
+
|
|
487
|
+
| Position | Type | Description | Example |
|
|
488
|
+
| :--- | :--- | :--- | :--- |
|
|
489
|
+
| 1 | `Element` | The window or UI element to maximize. | `element` |
|
|
490
|
+
|
|
491
|
+
#### Usage
|
|
492
|
+
```python
|
|
493
|
+
driver.execute_script('windows: maximize', element)
|
|
494
|
+
```
|
|
495
|
+
|
|
496
|
+
#### `windows: minimize`
|
|
497
|
+
Minimizes a window or UI element using the `WindowPattern`.
|
|
498
|
+
|
|
499
|
+
| Position | Type | Description | Example |
|
|
500
|
+
| :--- | :--- | :--- | :--- |
|
|
501
|
+
| 1 | `Element` | The window or UI element to minimize. | `element` |
|
|
502
|
+
|
|
503
|
+
#### Usage
|
|
504
|
+
```python
|
|
505
|
+
driver.execute_script('windows: minimize', element)
|
|
506
|
+
```
|
|
507
|
+
|
|
508
|
+
#### `windows: restore`
|
|
509
|
+
Restores a window or UI element to its normal state using the `WindowPattern`.
|
|
510
|
+
|
|
511
|
+
| Position | Type | Description | Example |
|
|
512
|
+
| :--- | :--- | :--- | :--- |
|
|
513
|
+
| 1 | `Element` | The window or UI element to restore. | `element` |
|
|
514
|
+
|
|
515
|
+
#### Usage
|
|
516
|
+
```python
|
|
517
|
+
driver.execute_script('windows: restore', element)
|
|
518
|
+
```
|
|
519
|
+
|
|
520
|
+
#### `windows: close`
|
|
521
|
+
Closes a window or UI element using the `WindowPattern`.
|
|
522
|
+
|
|
523
|
+
| Position | Type | Description | Example |
|
|
524
|
+
| :--- | :--- | :--- | :--- |
|
|
525
|
+
| 1 | `Element` | The window or UI element to close. | `element` |
|
|
526
|
+
|
|
527
|
+
#### Usage
|
|
528
|
+
```python
|
|
529
|
+
driver.execute_script('windows: close', element)
|
|
530
|
+
```
|
|
531
|
+
|
|
532
|
+
#### `windows: setFocus`
|
|
533
|
+
Sets focus to the specified UI element using UIAutomationElement's `SetFocus` method.
|
|
534
|
+
|
|
535
|
+
| Position | Type | Description | Example |
|
|
536
|
+
| :--- | :--- | :--- | :--- |
|
|
537
|
+
| 1 | `Element` | The UI element to set focus on. | `element` |
|
|
538
|
+
|
|
539
|
+
#### Usage
|
|
540
|
+
```python
|
|
541
|
+
driver.execute_script('windows: setFocus', element)
|
|
542
|
+
```
|
|
543
|
+
|
|
544
|
+
---
|
|
545
|
+
|
|
546
|
+
## 🛠 Development
|
|
547
|
+
|
|
548
|
+
Recommended VS Code plugin: [Comment tagged templates](https://marketplace.visualstudio.com/items?itemName=bierner.comment-tagged-templates) for syntax highlighting.
|
|
549
|
+
|
|
550
|
+
```bash
|
|
551
|
+
npm install # Setup dependencies
|
|
552
|
+
npm run lint # Code quality check
|
|
553
|
+
npm run build # Transpile TypeScript to JS
|
|
554
|
+
```
|