How to increment for loop index with some value instead of default 1

250 views
Skip to first unread message

Jaya Biradar

unread,
Jan 3, 2016, 6:00:37 AM1/3/16
to robotframework-users
how can we iterate for loop with some value . For example if i want to  increment by 30 how can i do?

currently i am doing like this 

for $i} IN RANGE 180

     DO something
     ${i}=  Set Variable ${i+30}



The result i am getting is like this:

i starts from 1

1. i=1
2, i=1+30
3. i=32
4. i=33


Its not getting incremented by 30 always.


I want perform like C language statement:

for (i=1;i<180;i+=30)
PLease let me know robot statement which resemble above C statement.


Thanks,
JaYa 

Mukesh T

unread,
Jan 3, 2016, 7:41:36 AM1/3/16
to robotframework-users
Hi,

This is mentioned in the user guide [1]. For specifying a step value, you can do it as follows-

Test For Loop With Step Value
    [Documentation]  Loops over values 1 to 180 with step 30
    :FOR    ${index}    IN RANGE    1    180    30
    \    Log    ${index}

Best,
Mukesh

Mukesh T

unread,
Jan 3, 2016, 7:43:01 AM1/3/16
to robotframework-users
Sorry, forgot to mention the link to user guide section [1]

[1]: http://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#for-in-range-loop
Reply all
Reply to author
Forward
0 new messages