GUI Test Configuration Through Script Arguments

GUI Test Configuration Through Script Arguments

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]
   startApplication(autCommand)
   ...
Florian joined froglogic in 2011 after working as a Software Developer and QA Engineer. Being a froglogic Consultant, he conducted dozens of Squish trainings, provided consulting services to froglogic clients, and gained experience working with QA departments across all industries. These days, his focus is on Technical Sales.

0 Avis

Laisser une réponse

Votre adresse de messagerie ne sera pas publiée. Les champs obligatoires sont indiqués avec *

*