Forum Discussion

TestQA1's avatar
TestQA1
Frequent Contributor
3 years ago

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 tha...
  • rraghvani's avatar
    3 years ago

    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]);
        }
    }