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 native = require("@nut-tree/nut-js");
const square = async (control) => {
await control.mouse.move(control.movement.right(500));
await control.mouse.move(control.movement.down(500));
await control.mouse.move(control.movement.left(500));
await control.mouse.move(control.movement.up(500));
};
const openSpotlight = async (control) => {
await control.keyboard.pressKey(native.Key.LeftSuper);
await control.keyboard.pressKey(native.Key.Space);
await control.keyboard.releaseKey(native.Key.Space);
await control.keyboard.releaseKey(native.Key.LeftSuper);
};
describe("Basic test", () => {
it("Should run a simple test", async () => {
const config = new native.Config();
const control = new native.Controller(config);
await square(control);
await openSpotlight(control);
await control.keyboard.type("calculator");
await control.keyboard.type(native.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
