0

Let's say I have two String variables: var1 and var2.

Is there any command on Selenium IDE (maybe storeEval with some javascript code), with which I can create an array and add the 2 variable values to it? Example:

var1 = "abc"

var2 = "def"

array = ("abc","def")

P.S: the array cannot have a fixed length. In this case I have just 2 variables, but in other scenarios I may have more than 10 variables, so I would need to create a loop and add all 10 variable values to the array.

Thanks!

Setily
  • 814
  • 1
  • 9
  • 21
ryoishikawa74
  • 177
  • 3
  • 11

1 Answers1

4

It's pretty simple but isn't obvious

storeEval | ['one','two']          | array
storeEval | storedVars['array'][1] | second
echo      | ${second}

Or simpler but with much less safety

storeEval | ['one','two']                      | array
echo      | javascript{storedVars['array'][1]}

Adding new item dynamically

getEval | storedVars['array'].push('three')

You can make loop using selenium IDE flow control for example. Like:

storeEval | 0                                                | i
while     | storedVars['i']<storedVars['array'].length
echo      | javascript{storedVars['array'][storedVars['i']]}
storeEval | ${i}+1                                           | i 
endWhile

I hope it will help

Antesser
  • 669
  • 4
  • 5