Chaining the Scripts

 

This feature lets you achieve the following:

  1. Invoking other web scripts from the current one.

  2. Controlling the order of execution of the web scripts that need to be played.

  3. Use Global Variables to set and get values from one script to another

Web Test Studio provides the following built-in functions to do so:

 

callScript

 

This will transfer the execution control to the called web script. The web script to be called and its location are specified as arguments.

 

callScript("<Web Script Name>","<Web Script Path>")

 

 

For example, assume the web script named test.wcs is present under webscripts/case1/test folder, then callScript is to be written as callScript("test","case1/test").

 

 

callScriptUpto

 

This will transfer the execution control to the called web script and execute up to the line number specifed. The web script to be called, its location and the line number are specified as arguments.

 

callScriptUpto("<Web Script Name>","<Web Script Path>",Line number)

 

 

For example, assume the web script named test.wcs is present under webscripts/case1/test folder and you want to execute up to script line numbered 120, then callScriptUpto is to be written as callScriptUpto("test","case1/test",120).

 

Points to remember

 

  • While specifying the Web Script Path, omit the webscripts folder.

  • Use forward slash ( / ) to specify the path.

  • If the called web script contains stop() then the calling script (till the parent script) will also be stopped.

    For example assume ScriptA calls ScriptB and that in turn calls ScriptC. ScriptC contains stop() command. Then, all the three webscripts will be terminated.

  • callScript() and callScriptUpto() can be written anywhere in the web script but it should be ensured that the parent webscript's flow is not disrupted.

    Assume the following:

    • ScriptA calls ScriptB.

    • ScriptA contains

      • launchApplication("about blank")

      • changeURL("www.google.com")

      • setWindow("google")

      • callScript("ScriptB","ScriptB")

      • setText("searchtext","web testing")

    • ScriptB contains

      • launchApplication("about blank")

      • changeURL("www.yahoo.com")

      • setWindow("yahoo")

      • setText("searchtext","functional testing")

This shows that after ScriptB is executed, when control returns to ScriptA the active window will not be "google" due to which setText("searchtext","web testing") will fail. This shows that callScript has been wrongly placed.

 

You can handle such cases by either inserting another changeURL("www.google.com") and setWindow("google") after callScript("ScriptB","ScriptB") or by inserting these at the end of ScriptB.

  • Test case results/reports  will be generated  under the parent web script directory only even if several other scripts had been invoked from it. But the script actions and test case result of the called scripts will be reported with the actual script name in the "remarks" column in addition to the actual remarks.

    For example, ScriptA calls ScriptB and that in turn calls ScriptC, then the test case results will be available under ScriptA only.

  •  Report will be generated only when the parent web script is executed completely.

  • If the called web script gets interrupted due to call to stop(), map_file_ not_found error , script_exception ,popup_handling error ,web_exception_handling etc., then the parent web script will not proceed further and it will be reported as CHILD_SCRIPT_FAILED.

 

Using Global Variables

 

You can set or get values in a global variable from one script to another using the setGlobal() and getGlobal() functions. You can refer to the usage of the functions in the following document.



Copyright © 1999, AdventNet Inc. All Rights Reserved.