简体   繁体   English

在机器人框架中使用For循环

[英]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. 我无法在Body中传递变量$ {ELEMENT}值,它只是从列表中获取最后一个值。 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}"}

put Set request body keyword inside for loop: 将Set request body关键字放入for循环中:

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}"}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM