SK Singh
SK Singh

Reputation: 35

Using For loop in robot framework

I am not able to pass the variable ${ELEMENT} values in the Body it just takes the last value from the list. I want to iterate it for all three values

Create Http Context    localhost:8080    http
Set Request Header    Content-Type    application/json
@{RecipientPhoneNumber} =    Create List    2162692764    21    2162792985
: FOR    ${ELEMENT}    IN    @{RecipientPhoneNumber}
\    Log    ${ELEMENT}
Set Request Body  {"id":"123456-789", "value":"${ELEMENT}"}

Upvotes: 1

Views: 1024

Answers (1)

soyacz
soyacz

Reputation: 457

put Set request body keyword inside for loop:

Create Http Context    localhost:8080    http
Set Request Header    Content-Type    application/json
@{RecipientPhoneNumber} =    Create List    2162692764    21    2162792985
: FOR    ${ELEMENT}    IN    @{RecipientPhoneNumber}
\    Log    ${ELEMENT}
\    Set Request Body  {"id":"123456-789", "value":"${ELEMENT}"}

Upvotes: 3

Related Questions