Search code examples
robotframework

How to use a RobotFramework keyword in a loop for x amount of selectors?


I have recently started to learn GUI automation with Robot Framework and I bumped into my first problem. I am trying to make a script that will test all confirmation dialogues on the website. My current solution for this is a custom keyword with all the tests in it, and then I call the keyword for each confirmation dialogue.

Test Confirmation Dialogue    ${CD1}
Test Confirmation Dialogue    ${CD2}
Test Confirmation Dialogue    ${CD3}
*
*
*

Is there a way to put this in some loop and avoid using the keyword once per confirmation dialogue?


Solution

  • Create a loop over all CD variables, and pass each to your keyword:

    FOR    ${cd}    IN    ${CD1}    ${CD2}   ${CD3}
        Test Confirmation Dialogue  ${cd}
    END