Native UI testing / controlling with node.js
This is a WIP implementation for a cross-platform native UI testing tool. It allows for native UI interactions via keyboard and / or mouse, but additionally gives you the possibility to navigate the screen based on image matching.
The following snippet shows a valid NUT example (on macOS)
"use strict";
const { keyboard, Key, mouse, movement } = require("@nut-tree/nut-js");
const square = async () => {
await mouse.move(movement.right(500));
await mouse.move(movement.down(500));
await mouse.move(movement.left(500));
await mouse.move(movement.up(500));
};
const openSpotlight = async () => {
await keyboard.pressKey(Key.LeftSuper);
await keyboard.pressKey(Key.Space);
await keyboard.releaseKey(Key.Space);
await keyboard.releaseKey(Key.LeftSuper);
};
describe("Basic test", () => {
it("Should run a simple test", async () => {
await square();
await openSpotlight();
await keyboard.type("calculator");
await keyboard.type(Key.Return);
});
});nut-tree/trailmix contains a set of ready to use examples which demo the usage ot nut.js.
This list gives an overview on currently implemented and planned functionality. It's work in progress and will undergo constant modification.
- Copy text to clipboard
- Paste text from clipboard
- Support for standard US keyboard layout
- Support for German special characters
- Support for mouse movement
- Support for mouse scroll
- Configurable movement speed
- Mouse drag
- Retrieve the region of a process window
- findOnScreen
- waitFor
- Hooks to trigger actions based on images
- Jest
