sidorares / nierika

pixel based testing library with VNC as a driver
MIT License
12 stars 0 forks source link

nierika

Greenkeeper badge

Visual testing library, heavily inspired by Sikuli / SikiliX

nierika

Installation

npm install --save nierika

Api

At the moment only VNC is supported as screen driver. You start by constructing screen object:

const nierika = require('nierika')
const opts = {
  host: '127.0.0.1',
  port: 5911,
  password: 'my-new-password',
  encodings: [rfb.encodings.raw, rfb.encodings.pseudoCursor] // optional
};

const screen = nierika.createScreen(opts)

Screen object

const template = await screen.createTemplateFromFile(path) - create template using image file file from disk. Returns Template

const match = await screen.waitVisible(template, timeout) - wait until template is visible on screen.

const match = await screen.waitVanish(template, timeout) - wait until template is NOT visible on screen.

await screen.mouseMove(x, y) - move mouse to x, y

await screen.mouseMove(template) - wait until template is visible and move mouse to match position

await screen.mouseLeftClick()

await screen.mouseLeftDoubleClick()

await screen.mouseWheeDown()

await screen.mouseWheelUp()

await screen.keyboardTypeText(string) - type text

await screen.keyboardKeyUp(string|number), await screen.keyboardKeyDown(string|number) - if argument is number, send numerical keysym. If it's a string, use it as a name to lookup keysym using keysym module.

Template object

template.similar(similarity) - return new template with similarity set to similarity

template.width(), template.height()

Using from docker container

1) (optional, unless you already have vnc server somewhere): start docker run --name vnc -p 5911:5901 -p 6901:6901 -e "VNC_PW=my-new-password" consol/centos-xfce-vnc 2) modify tests to use host: "vnc", port: 5901, password: "my-new-password" credentials 3) git pull sidorares/nierika:1.1 4) docker run -it --link vnc:vnc -v [path-to-your-tests-folder]:/test sidorares/nierika:1.1

TODO

Similar projects

Thanks

@glenngillen for running 'New Year resolution to finish a project' meetup where I finnally put pieces of code together as first version of this lib