Forum Discussion

TestQA1's avatar
TestQA1
Frequent Contributor
3 years ago
Solved

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.
  • In JavaScript (not JScript) you need to access Excel collection items by using the .Items property:

     

    book.Sheets(sheetName) => book.Sheets.Item(sheetName)
    app.Cells(1,1) => app.Cells.Item(1,1)

    etc.

     

    More details here: https://support.smartbear.com/viewarticle/82954/#collections

     

    Also, you can't assign to a cell directly because it's an object, you need to use something like:

    app.Cells.Item(1,1).Value2 = "test";