Using Global Variables

 

You can set or get values in a global variable across scripts or from one script to another while using the callScript(). You can setGlobal("<variable_name>","<variable_value>") in script1, and in script10 you can get the global variable value using getGlobal("<variable_name>"). The syntax and usage for setting and getting global variable values are as follows:

 

You can use the Global Variables Editor screen to configure the global variables. Please refer to the context sensitive help for details.

 

Syntax:

 

setGlobal("<variable_name>","<variable_value>")

getGlobal("<variable_name>")

 

Usage: The usage of setGlobal() and getGlobal() functions are given below:

 

Example: 1

 

setGlobal("qehome","file:\\C:\test\WebTest\QEngineWebTest\examples\payrollsystem\index.html")

 

You can get the variable value in your script as below

 

getGlobal("qehome") or store it in a variable as myhome=getGlobal("qehome").

 

Example: 2

 

Assume you have three scripts script1, script5 and script6. script1 sets the global variable values and in a for loop using the callScript() calls the scripts (script5 and script6) from where the global variable value is accessed using the getGlobal() to set the values in the setText() statements.

 

Example Script (script1) sets the global variable values and calls the scripts (script5 and script6) using the callScript().

 

useLocalMapFile()

launchApplication("about:blank")

changeURL("file://$QE_HOME/examples/payrollsystem/index.html",2)

setWindow( "AdventNet Payroll System",2)

clickElement("AdventNet ",2)

clickList("View",2)

setWindow( "AdventNet Payroll System Package - Form to View Employee Details",2)

initCSV("$APPHOME/test.csv")

for i in range(0,2):

setGlobal("name",getCSVValueAt(i,1))

callScript("script5","script5")

for i in range(0,4):

setGlobal("dept",getCSVValueAt(i,2))

callScript("script6","script6")

closeWindow( "AdventNet Payroll System Package - Form to View Employee Details",2)

 

Example Script (script5) being called by script1 uses the getGlobal() to get the global variable value and set it in the setText() statement.

 

useLocalMapFile()

setWindow( "AdventNet Payroll System Package - Form to View Employee Details",2)

setText("yourname",getGlobal("name"),2)

 

Example Script (script6) being called by script1 uses the getGlobal() to get the global variable value and set it in the setText() statement.

 

useLocalMapFile()

setWindow( "AdventNet Payroll System Package - Form to View Employee Details",2)

setText("dept",getGlobal("dept"),2)

 



Copyright © 1999, AdventNet Inc. All Rights Reserved.