[英]Keeping same variable name inside a keyword
Anyone know is it possible for the keyword to keep same variable name as it received?任何人都知道关键字是否可以保持与收到的相同的变量名?
Following short example will add values to list.以下简短示例将向列表添加值。 Once it has been updated it needs to be set as a new variable (If i add "${first_list_values}" as test variable after new list insertion, it will only work with one specific list) and the same keyword can't be used anymore.更新后,需要将其设置为新变量(如果我在新列表插入后添加“${first_list_values}”作为测试变量,它将仅适用于一个特定列表)并且不能使用相同的关键字了。
Id much rather use same keyword to loop multiple lists.我宁愿使用相同的关键字来循环多个列表。
**Keyword**
Change List value
[Arguments] ${received_list}
${new_list} Insert Into List ${received_list} 0 xxx
Set Test Variable ${new_list}
**Test Cases*
Checking new list values
Change List value ${first_list_values}
Maybe something like this:也许是这样的:
*** Settings ***
Library Collections
*** Variables ***
@{ORIGINAL_LIST} First Second
*** keywords ***
Change List value
[Arguments] ${received_list}
Append to List ${received_list} Appended Third Appended Fourth
[return] ${received_list}
*** Test cases ***
Use Return
Log To Console ORIGINAL_LIST: @{ORIGINAL_LIST}
@{ORIGINAL_LIST}= Change List value ${ORIGINAL_LIST}
Log To Console ORIGINAL_LIST AFTER CHANGE: @{ORIGINAL_LIST}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.