TestQA1
3 years agoFrequent Contributor
Creating array with Project variable
Hi,
I have a func that repeats in different Scenarios of feature.
function test() {
If (a> b) {
a = project.variable.temp
}
}
Now I need to have an array variable inside the function that stores the values of 'a' each time the function is called in Scenarios and then finally return itself from the function as a normal array. Something like when scenario1 runs this function, 'a' would be 3, then 2,6,0 in rest of the scenaris and the final array would be finalarray = {3,2,6,0} . So when I need to get its value in another function i can simply call by index.
Any help is appreciated.
Thankyou.
I have a func that repeats in different Scenarios of feature.
function test() {
If (a> b) {
a = project.variable.temp
}
}
Now I need to have an array variable inside the function that stores the values of 'a' each time the function is called in Scenarios and then finally return itself from the function as a normal array. Something like when scenario1 runs this function, 'a' would be 3, then 2,6,0 in rest of the scenaris and the final array would be finalarray = {3,2,6,0} . So when I need to get its value in another function i can simply call by index.
Any help is appreciated.
Thankyou.
You can initialise the object type at the very beginning of the script (global variable),
// Temporary project (or suite) variable of type Object Project.Variables.TempArray = new Array(); function test1() { // Add Project.Variables.TempArray.push("3"); } function test2() { // Add Project.Variables.TempArray.push("2"); } function test3() { // Print for (var i = 0; i < Project.Variables.TempArray.length; i++) { Log.Message(Project.Variables.TempArray[i]); } }