This feature lets you achieve the following:
Invoking other web scripts
from the current one.
Controlling the order
of execution of the web scripts that need to be played.
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
|
|
|
|
|
|
|
|
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.
|
|
|
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. Refer Configuring Global Variables to configure suite level global variables.