Broken with following task: i want to set the name of variable in loop, like:
for i in 10:
${i}line = some value
How this can be done in Robot framework and if this is possible?
Thank you.
P.S. Sorry for dummy questions =\
Broken with following task: i want to set the name of variable in loop, like:
for i in 10:
${i}line = some value
How this can be done in Robot framework and if this is possible?
Thank you.
P.S. Sorry for dummy questions =\
FOR / IN Scenario:
FOR/IN statement is used as a loop for items in f.e. lists. The example below has these steps:
@{list}= Create List Var1 Var2 Var3
${index} Evaluate 1
${line} Set Variable line
:FOR ${i} IN @{list}
Set Test Variable ${${index}${line}} ${i}
${index} Evaluate ${index}+1
Create list with some variables
Run loop through the list
Set dynamic test variable by catenating the ${index} value with ${line} string. This test variable holds the ${i} value looped from @{list}.
Evaluate index value by 1
Results:
${1line} = Var1
${2line} = Var2
${3line} = Var3
FOR / IN RANGE Scenario:
However, we can use range loop if the scenario requires running loop for certain number of times.
${line} Set Variable line
:FOR ${i} IN RANGE 10
Set Test Variable ${${i}${line}} ${i}
${i} variable is raised by one each time we use loop until the range 10 is reached.
Results:
${1line} = 1
${2line} = 2
....
${10line} = 10