Reputation: 470
newbie to the robot framework. I am trying to have a for loop within the keywords.
So the for loop will increase from 1 to 9 and replace the variable that i inserted into the XPath
*** Variables ***
${MAX} 9
*** Keywords ***
Go to data gov sg page
[Arguments] ${MAX}
:FOR ${EACH} IN ${MAX}
\ click element xpath:/html/body/main/div/div/div/div[${EACH}]/a
Currently the issue now is that it is not looping and going straight to 9. Not looping from 1..2...9.
Would appreciate if someone can take a look at it.
Upvotes: 0
Views: 1840
Reputation: 2813
It seems forgot to use range function you can do like-
FOR ${INDEX} IN RANGE 1 ${MAX+1}
click element xpath:/html/body/main/div/div/div/div[${INDEX}]/a
END
Reference - new style of for loop in RF 3.1 release
Upvotes: 3