简体   繁体   English

在关键字中保持相同的变量名

[英]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.

相关问题 是否可以在名称中声明带有 arguments 的关键字? - Is it possible to declare a keyword with arguments inside the name? 找到多个具有相同名称的关键字,但只有唯一的关键字 - Multiple Keywords with same name found but there is only unique keyword 在机器人框架中运行相同的关键字将变量重置为无 - Running same keyword reset variable to none in robot framework 机器人框架:从用户定义的关键字中的用户关键字中获取选择会引发错误“关键字名称不能为空” - Robot Framework: get selection from user keyword inside a user defined keyword throws error 'Keyword name cannot be empty' 如何将返回的变量从关键字传递给相同和不同类的另一个 - How to pass a returned variable from a keyword to another of same and different class Robot Framework如何使用变量库名称调用关键字 - Robot Framework how to call keyword with variable library name 在机器人框架中,是否有一种方法可以在关键字中打印嵌入参数的变量值而不是变量名? - In robot framework is there a method to print the variable value of the embedded argument in keyword rather than the variable name? 在机器人中找不到名称为“=”的关键字 - No keyword with name '=' found in robot 找不到名为“RowCnt”的关键字 - No keyword with name 'RowCnt' found “运行关键字如果”并设置变量 - "Run Keyword If" and setting a variable
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM