Migrations
2.0.0
Breaking changes introduced with nut.js version 2.0.0
ImageFinder Providers
@nut-tree/nut-js
introduced a plugin system and no longer ships image matching code by default. To use image matching functionality one will have to install an additional package, providing the actual implementation to perform image comparison. Otherwise, all functions relying on image matching will throw an error like Error: No ImageFinder registered
.
One available option would be @nut-tree/template-matcher
:
If you want to keep using your existing setup, install a suitable provider, e.g. above mentioned package.
npm i @nut-tree/template-matcher
To use this provider package, simply require it in your code, e.g. index.js
:
const {screen} = require("@nut-tree/nut-js");
require("@nut-tree/template-matcher"); // THIS IS NEW
Screen.find
Template Images
Template images are no longer loaded from screen.config.resourceDirectory
by default. Instead, an Image
has to be passed.
If you want to keep using your existing setup, you can wrap the image filename in a call to imageResource
.
// Pre 2.0.0
const image = await screen.find("file.png");
// 2.0.0
const image = await screen.find(imageResource("file.png"));
Screen.waitFor
Template Images
Template images are no longer loaded from screen.config.resourceDirectory
by default. Instead, an Image
has to be passed.
If you want to keep using your existing setup, you can wrap the image filename in a call to imageResource
.
// Pre 2.0.0
const image = await screen.waitFor("file.png", 3000);
// 2.0.0
const image = await screen.waitFor(imageResource("file.png"), 3000);
Configurable interval
The update interval used by waitFor
used to be fixed to 500ms.
With release 2.0.0, waitFor
received an additional parameter to configure this interval.
If you want to keep using your existing setup, pass an interval of 500ms to waitFor
.
// Pre 2.0.0
const image = await screen.waitFor("file.png", 3000, {searchRegion: new Region(100, 100, 100, 100)});
// 2.0.0
const image = await screen.waitFor("file.png", 3000, 500, {searchRegion: new Region(100, 100, 100, 100)});
LocationParameters
The LocationParameters
object has been dropped. Please use OptionalSearchParameters instead.