Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

For loop using robot framework with 2 parameters

I have two list variables @{vinrange} and @{sg} both with same dimensions of 4 enter image description here

I want to print into the LOG using the scalar ${VAR1} for each value from the list variable @{vinrange} and print using a second scalar ${VAR2} for each value from the list variable @{sg}

I have to assign both of them into the same loop, the ${VAR1}[1] has worked for the @{vinrange}, however, I don't know how to do for the second list variable @{sg}.

enter image description here

like image 293
Rafael Rodrigues Santos Avatar asked Dec 31 '22 23:12

Rafael Rodrigues Santos


1 Answers

There is a FOR construct version precisely for this situation - to iterate over two lists simultaneously - that is with IN ZIP, link to the documentation .
It expects two or more iterables (like lists), and on every iteration returns the values of each at the same index.

Note that it will stop at the shorter one's last element (e.g. if their lengths are different, it won't raise an exception, nor it will fully exhaust the longer list). So for your case:

FOR    ${vinrange_element}    ${sg element}    IN ZIP     ${vinrange}       ${sg}
     Log      ${vinrange element} 
     Log      ${sg element}
END
like image 157
Todor Minakov Avatar answered Jan 02 '23 12:01

Todor Minakov