Your first scenario should work as long as it’s all done during a single execution. EG:
Global gTest
put "Hello Global" into gTest
script2 // Call script 2 will output "Global gTest"
Global variables do not persist from one run to the next. So if you call script2 after the first script finishes then it’ll be empty. You can use “universal” variables if you want them to persist for the duration of you Eggplant session (they will go away when you quit Eggplant).
Thanks, Jonathan! Let me state the problem we want solution for
We want to declare the Images’ path in variables in a common script and use them in separate script.
script 1
like set global applImages to “\Main\Sub\Sub1”
script 2
set myImage to global appImages&"\myImage"
That is a very common usage and it should work fine as long as you run both scripts in the same session and either declare the variable as global at the beginning of the handler: global applImages
or always refer to it with the word global in front: set myImage to global appImages & “\myImage”.
Thanks! As I understand that these variables will not be set unless that script is run. So we cannot have a helper suite as library to hold these variables and refer these variablesto get the values set in the helper library.
You can certainly chain calls of scripts together in Eggplant so you CAN definitely setup a variable in a helper script or helper suite and THEN call your primary scripts.
Here is a simple example suite showing access to global variables.