Now that we have covered how to interact with an operating system and used screenshot based testing capabilities of Sakuli, we can move on how to utilize one or multiple applications. All features are incorporated in the ThenableApplication Interface.
To open an application, you enter the path to the application or respectively the application name, if you already
added it to your PATH environment variable. If your path contains spaces, you have to escape them with
\\ because white spaces are reserved for parameter separation.
// path to excel 'C:\\path to excel \excel.exe' const excel = new Application("C:\\path\\ to\\ excel\excel.exe"); await excel.open(); // open browser with parameters const chromium = new Application("chromium-browser --incognito --proxy-server=localhost:1234"); await chromium.open(); // path to chrome is e.g. 'C:\\Program\\ Files\google-chrome\chrome.exe' const chrome = new Application("C:\\Program\\ Files\google-chrome\chrome.exe --incognito"); await chrome.open();
After creating an application with
new Application(), it is necessary to call
open() for Sakuli to start it.
setSleepTime(seconds) you can set the waiting time after opening an application. This is particularly useful for
larger applications that have an initial loading time.
const calc = new Application("gnome-calculator"); //sleepTime of 1 second await calc.setSleepTime(1) .open();
You can either use
close() sends a
SIGTERM signal and
SIGKILL signal to end the
await calc = new Application('gnome-calculator').open(); await calc.close(); await calc.kill(); //throws an exception if ending the process fails await calc.close(false); await calc.kill(false);
Currently (Sakuli v2.3.0) it is not possible to get the region from the application or the focused window. Therefore the following methods will return the desktop instead.
const calc = new Application('gnome-calculator'); await calc.open() .getRegion(); await calc.open() .getRegionForWindow();