4.2.0 • Published 14 days ago

@nut-tree/nut-js v4.2.0

Weekly downloads
19,634
License
Apache-2.0
Repository
github
Last release
14 days ago

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

About

nut.js is 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 { keyboard, Key, mouse, left, right, up, down } = require("@nut-tree/nut-js");

const square = async () => {
  await mouse.move(right(500));
  await mouse.move(down(500));
  await mouse.move(left(500));
  await mouse.move(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);
  });
});

Installation

nut.js comes with a pre-built version of OpenCV for your respective target platform. In order to use these pre-compiled bindings, certain runtime conditions have to be met.

Prerequisites

This section lists runtime requirements for nut.js on the respective target platform.

Windows

In order to install nut.js on Windows, please make sure to have the Microsoft Visual C++ Redistributable installed.

macOS

On macOS, Xcode command line tools are required. You can install them by running

xcode-select --install

Linux

Depending on your distribution, Linux setups may differ.

In general, nut.js requires

  • libXtst

Installation on *buntu distributions:

sudo apt-get install libxtst-dev

Setups on other distributions might differ.

Manual build

As a fallback, nut.js is able to build all required dependencies by itself. To do so, some setup is required on the respective target platform.

Windows

In order to install nut.js on Windows, Windows Build Tools and Python 2 are required. You can either set them up manually, or install them via npm:

npm install --global windows-build-tools

or

yarn global add windows-build-tools

macOS

On macOS, Xcode command line tools are required. You can install them by running

xcode-select --install

Linux

Depending on your distribution, Linux setups may differ.

In general, nut.js requires

  • Python 2
  • g++
  • make
  • libXtst
  • libPng

Installation on *buntu distributions:

sudo apt-get install build-essential python libxtst-dev libpng++-dev

Setups on other distributions might differ.

For reference, please see:

Install nut.js

Running

npm i @nut-tree/nut-js

or

yarn add @nut-tree/nut-js

will install nut.js and its required dependencies.

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
4.2.0

14 days ago

4.1.0

21 days ago

4.0.1

27 days ago

4.0.0

2 months ago

3.1.2

11 months ago

3.1.1

1 year ago

3.1.0

1 year ago

3.0.0

1 year ago

2.3.0

2 years ago

2.2.1

2 years ago

2.2.0

2 years ago

2.1.1

2 years ago

2.1.0

2 years ago

2.0.1

2 years ago

2.0.0

2 years ago

2.0.0-RC1

2 years ago

1.7.0

3 years ago

1.6.0

3 years ago

1.5.0

4 years ago

1.4.2

4 years ago

1.4.1

4 years ago

1.4.0

4 years ago

1.3.3

4 years ago

1.3.2

4 years ago

1.3.1

4 years ago

1.3.0

5 years ago

1.2.1

5 years ago

1.2.0

5 years ago

1.1.2

5 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago

0.1.0-beta.3

5 years ago

0.1.0-beta.2

5 years ago

0.1.0-beta.1

5 years ago

0.1.0-beta.0

5 years ago

0.0.4

5 years ago

0.0.3

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago