@@ -13,6 +13,10 @@ Native UI testing / controlling with node.js
1313
1414# About
1515
16+ <p align =" centet " >
17+ <img src=".gfx/nut.png" alt="logo" width="200"/>
18+ </p >
19+
1620This is a WIP implementation for a cross-platform native UI testing tool.
1721It allows for native UI interactions via keyboard and / or mouse,
1822but additionally gives you the possibility to navigate the screen based on image matching.
@@ -26,28 +30,32 @@ The following snippet shows a valid NUT example (on macOS)
2630
2731const native = require (" native-ui-toolkit" );
2832
29- const square = async (controller ) => {
30- await controller .mouse .move (controller .movement .right (500 ));
31- await controller .mouse .move (controller .movement .down (500 ));
32- await controller .mouse .move (controller .movement .left (500 ));
33- await controller .mouse .move (controller .movement .up (500 ));
33+ const square = async (control ) => {
34+ await control .mouse .move (control .movement .right (500 ));
35+ await control .mouse .move (control .movement .down (500 ));
36+ await control .mouse .move (control .movement .left (500 ));
37+ await control .mouse .move (control .movement .up (500 ));
3438};
3539
40+ const openSpotlight = async (control ) => {
41+ await control .keyboard .pressKey (native .Key .LeftSuper );
42+ await control .keyboard .pressKey (native .Key .Space );
43+ await control .keyboard .releaseKey (native .Key .Space );
44+ await control .keyboard .releaseKey (native .Key .LeftSuper );
45+ }
46+
3647describe (" Basic test" , () => {
3748 it (" Should run a simple test" , async () => {
3849 const config = new native.Config ();
3950 const control = new native.Controller (config);
4051
4152 await square (control);
42-
43- await control .keyboard .pressKey (native .Key .LeftSuper );
44- await control .keyboard .pressKey (native .Key .Space );
45- await control .keyboard .releaseKey (native .Key .Space );
46- await control .keyboard .releaseKey (native .Key .LeftSuper );
53+ await openSpotlight (control);
4754 await control .keyboard .type (" calculator" );
4855 await control .keyboard .type (native .Key .Return );
4956 });
5057});
58+
5159```
5260
5361# Examples
0 commit comments