Quantcast
Channel: froglogic
Viewing all articles
Browse latest Browse all 398

Register an application through a testscript

$
0
0

Motivation

I am asked fairly frequently, “The path to my application changes on a daily basis. How can I automatically update the path to the squishserver?”

This article will show how to change the path to the Application Under Test via a test script. I will use Squish for Java, Javascript, and the Swing addressbook example application to demonstrate this. I will refer to the ‘Application Under Test’ simply as the ‘AUT’ from now on.

Example

I start with the squishserver command to register an application. This leads to a changed path for already registered applications.

function registerAut(autName, pathToAut){
    cmd = 'squishserver --config addAUT "' + autName + '" "' + pathToAut + '"';
    capture = OS.capture(cmd);
}

To execute the function shown above, the path to the AUT has to be determined. To do so for this example, I created the following function:

function getPathToAut(autName) {
    pathToAut = OS.getenv("SQUISH_PREFIX") + "\\examples\\java\\addressbook\\";
    return pathToAut
}

The last missing step is to start the AUT after the registration. The complete code looks like this:

function main() {
    registerAndStartMyAut("AddressBookSwing.jar");
    snooze(1)
}

function registerAndStartMyAut(autName) {
    pathToAut = getPathToAut();
    registerAut(autName, pathToAut);
    return startAut(autName)
}

function getPathToAut() {
    pathToAut = OS.getenv("SQUISH_PREFIX") + "\\examples\\java\\addressbook\\";
    return pathToAut
}

function registerAut(autName, pathToAut){
    cmd = 'squishserver --config addAUT "' + autName + '" "' + pathToAut + '"';
    capture = OS.capture(cmd);
}

function startAut(autName) {
    return startApplication('"' + autName + '"')
}

As you saw above, to register an application through a test case isn’t a big deal. The more complicated part is to determine the path to the AUT correctly.

The given code is transferable to all other Squish editions or scripting languages without any problem.

The post Register an application through a testscript appeared first on froglogic.


Viewing all articles
Browse latest Browse all 398

Trending Articles