Skip to content

Repository files navigation

nut.js (Native UI Toolkit) Build Status Greenkeeper badge SonarCloud badge

Native UI testing / controlling with node.js


Built with Robot Built with opencv4nodejs

About

logo

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.

Sample

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);
    });
});

Examples

nut-tree/trailmix contains a set of ready to use examples which demo the usage ot nut.js.

Modules

This list gives an overview on currently implemented and planned functionality. It's work in progress and will undergo constant modification.

Clipboard

  • Copy text to clipboard
  • Paste text from clipboard

Keyboard

  • Support for standard US keyboard layout
  • Support for German special characters

Mouse

  • Support for mouse movement
  • Support for mouse scroll
  • Configurable movement speed
  • Mouse drag

Process

  • Retrieve the region of a process window

Screen

  • findOnScreen
  • waitFor
  • Hooks to trigger actions based on images

Integration

  • Jest

About

Native UI testing / controlling with node

Topics

Resources

Contributing

Stars

2.9k stars

Watchers

23 watching

Forks

Releases

Sponsor this project

Packages

Used by

Contributors

Languages