Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Include a loop in a loop in Robot Framework

I've got a problem with using a loop in another existing loop in RF That is just an example of what I need: I have a list of people (@{people}) and each of the people has a list of items.

I do the following:

:FOR | ${person} | IN @{people} 
\ | @{items}= | Create List | xpath=//div[@class='item'] 
\ | :FOR ${item} | IN @{items} 
\ | \ | ...

The problem is on the second :FOR I got an error 'keyword :FOR is not found'. Do I do something wrong? Or is there any other way to include a loop in another loop?

like image 227
Anastasia Chistokhvalova Avatar asked Jan 07 '23 18:01

Anastasia Chistokhvalova


1 Answers

According to User Guide, having nested for loops is not supported directly, but it is possible to use a user keyword inside a for loop and have another for loop there

*** Keywords ***
Loop over people
    :FOR  ${person}  IN  @{people} 
    \  @{items}=  Create List  xpath=//div[@class='item'] 
    \  Loop over items  @{items}

Loop over items    
    [Arguments]  @{items}
    :FOR  ${item}  IN  @{items} 
    \  ...
like image 72
Laurent Bristiel Avatar answered Jan 19 '23 05:01

Laurent Bristiel