https://github.com/richienb/windows-app
Automate Windows applications.
https://github.com/richienb/windows-app
Last synced: 9 months ago
JSON representation
Automate Windows applications.
- Host: GitHub
- URL: https://github.com/richienb/windows-app
- Owner: Richienb
- License: mit
- Created: 2020-09-28T12:45:04.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2022-09-17T12:47:23.000Z (over 3 years ago)
- Last Synced: 2024-10-18T13:16:35.362Z (about 1 year ago)
- Language: JavaScript
- Size: 2.25 MB
- Stars: 14
- Watchers: 3
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: readme.md
- License: license
Awesome Lists containing this project
README
# windows-app
Automate Windows applications.
## Install
```sh
npm install windows-app
```
This module vendors [Windows Application Driver](https://github.com/microsoft/WinAppDriver#readme). You will need to [enable developer mode](https://docs.microsoft.com/windows/apps/get-started/enable-your-device-for-development#activate-developer-mode-sideload-apps-and-access-other-developer-features) yourself.
## Usage
```js
import windowsApp from 'windows-app';
const {select, close} = await windowsApp('Microsoft.WindowsCalculator_8wekyb3d8bbwe!App'); // Calculator app
await select.name_('One').click();
await select.name_('Plus').click();
await select.name_('Two').click();
await select.name_('Equals').click();
const result = Number((await select.accessibilityId('CalculatorResults').getText()).replace('Display is', ''));
console.log(`The result of 1 + 2 is ${result}`);
//=> 'The result of 1 + 2 is 3'
await close();
```
## API
### windowsApp(appId, options?)
Launch the specified application and provide options to manipulate it.
Only one application can be launched at a time.
#### appId
Type: `string`
The path to an exe file or the id of a UWP.
#### options
Type: `object`
##### timeout
Type: `integer | false`\
Default: `10000`
The timeout for interactions with elements and application startup in milliseconds. Set to `false` to disable.
#### Return value
##### select.xPath(xPath)
##### select.class(class_)
##### select.id(id)
##### select.name_(name)
##### select.accessibilityId(accessibilityId)
Select an element in the launched application.
##### driver
The [`selenium-appium`](https://github.com/react-native-windows/selenium-appium#readme) driver for lower-level testing.
##### close()
Close the application and end all associated processes. Returns a promise that resolves when completed.
## Tips
- Use [Accessibility Insights](https://accessibilityinsights.io) to inspect applications in order to get element names.