GUI test exeutions have to be configured for various purposes. Test engineers might want to configure a test in order to use specific test data as input to the Application Under Test. Or the Application Under Test itself has to be executed with a variation of program arguments.

While many tests are self-contained, there are cases in which the configuration is done externally, for example through a scheduler that drives the test executions, such as a Continuous Integration server. In these cases, the squishrunner executable can be used to pass arguments to the test scripts. The test script may access those arguments and adopt its behaviour based on the values.

Passing Script Arguments to squishrunner

The squishrunner option that supports this is called --scriptargs. It has to be specified at the very end of the complete squishrunner command call. All arguments which are specified after --scriptargs are passed to the executed script.

The following example shows a squishrunner call that passes two arguments to the test script:

./squishrunner --testsuite /path/to/suite --testcase tst_case1 --reportgen xml3.2,/path/to/result --scriptargs argument1 argument2

Accessing these arguments in the test script depends on the scripting language that is used. Assuming that Python is used, we need to use the sys module which provides a list of command line arguments through the argv variable. The following snippet shows how to log all arguments to the Squish Test Result. Visit the Squish documentation to learn how to access arguments in JavaScript test scripts.

import sys
def main():
    test.log('Number of arguments:' + str(len(sys.argv)) + 'arguments.')
    test.log('Argument List: ' + str(sys.argv))

When executing the snippet above, you will notice that the first field, argv[0], holds the name of the script itself. This is common practice in many scripting languages. The first argument we pass to the squishrunner --scriptargs option can be accessed through argv[1].

Configuring an Example Application through Script Arguments

Let’s get back to one of the initial examples: we want to pass a program argument to configure the AUT. Let’s assume this argument is called --nolauncher --autoconnect. The command for such an application startup could look like this:

./exampleApplication --nolauncher --autoconnect

To pass these arguments to the test script, the squishrunner call would look like this:

./squishrunner --testsuite /path/to/suite --testcase tst_case1 --reportgen xml3.2,/Users/flo/tmp/result --scriptargs --nolauncher --autoconnect

Finally, we need to access the arguments in the test script itself, and pass it to the startApplication call:

import names
import sys

def main():
    autCommand = "exampleApplication"
    for i in range(1, len(sys.argv)):
        autCommand = autCommand + " " + sys.argv[i]


Is there a way to pass the argument to the test script(s) when running them from the Squish IDE?

    At the moment, the Squish IDE does not support this. Thus it’s recommended to implement a fallback branch to make sure that the script works even if no script argument is passed, for example by setting a default value. Anyway, I forwarded this as a feature request to our product management. Thanks a lot for your feedback!

Is there any way to pass input value from Squish to external terminal?


Leave a Reply

Your email address will not be published. Required fields are marked *

Copy link
Powered by Social Snap