Execute command - operation

Run arbitrary JavaScript code directly on the device.


This operation is only supported on HTML based platforms.

To perform this operation in the Suitest Test editor use the Execute command line:

Enable the hidden debug mode
Enable the hidden debug mode

To perform this operation in the Suitest JavaScript API use the executeCommand command:

await suitest.executeCommand("window.myApp.debugMode = 1");

Usage

Sometimes it is necessary to make certain preparations for the test scenario or augment the app to make it behave in a certain way. For example you may want to turn off pop-ups, set a specific location for your app, turn on the debug mode, etc.

Execute command will execute the specified JavaScript on the client without collecting the results. However should the JavaScript code produce an exception the test scenario will fail with the exception message.

You can specify an arbitrary JavaScript code but be careful about the code that produces side effects. For example, consider a silly piece of code like this:

var a = 1;

This code is creating a variable in the global scope. If the application happens to use such variable internally, this code may just have corrupted its runtime and thus the test results can not be considered reliable anymore.

Generally you should use this subject only if you are sure that there is no other way to achieve the desired result. When in doubt on how to structure your JavaScript consult with your development team.