简体   繁体   English

机器人框架::如何计算参数?

[英]Robot FrameWork:: How to Count Arguments?

Is there any way to dynamically Count how many Arguments has been passed to a keyword AND is there a way to print arguments like Log ${Argument1}, ${Argument2}?. 是否有任何方法可以动态计算已将多少个参数传递给关键字,并且有没有办法打印诸如Log $ {Argument1},$ {Argument2}之类的参数? for Eg There are some 10 check boxes to select. 例如,有大约10个复选框可供选择。 but in TC QA selects only few items which he/she sends as argument to a keyword. 但在TC中,质量检查人员只会选择他/她作为参数发送给关键字的少量项目。 So, We want to capture all the list of arguments to create a List and iterate through them to select the right check boxes 因此,我们要捕获所有参数列表以创建一个列表并遍历它们以选择正确的复选框

Add Arguments to List
    [Arguments]   arg1  arg2  arg3  arg4  arg5 
    ${NoOf_Arguments}  =   #TODO: no idea how to count no of arguments
    @{List_To_Create}=  Create List
    : For ${item}  IN RANGE ${NoOf_Arguments}
    \   append to list  ${List_To_Create} ${item}
    [Return]  ${List_To_Create}  

Robot supports a variable number of arguments by having the last item in [Arguments] be a list variable. Robot通过将[Arguments]中的最后一项作为列表变量来支持可变数量的参数。

For example: 例如:

*** Keywords ***
A keyword
    [Arguments]  @{args}
    ${count}=  get length  ${args}
    log  you passed in ${count} arguments
    :FOR  ${arg}  IN  @{args}
    \  log  argument: ${arg}
    [return]  ${count}    

*** Test cases ***
Example
    ${result}=  A keyword  arg1  arg2  arg3
    should be equal as numbers  ${result}  3

    ${result}=  A keyword  arg1  arg2  arg3  arg4  arg5
    should be equal as numbers  ${result}  5

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

相关问题 如何在机器人框架中传递默认的可变参数? - How to pass default mutable arguments in robot framework? 在机器人框架中使用命名参数 - Use of named arguments in robot framework 在Robot Framework中用引号引起的参数问题 - Issue with arguments with quotes in Robot Framework 如何在机器人框架中保存嵌入式参数的先前实例? - How to save the previous instance of embedded arguments in robot framework? 如何使用随变量文件传递的额外参数 - 机器人框架 - How to use extra arguments passed with Variable file - Robot framework 如何在机器人框架中为 Read Csv As Dictionary 提供参数 - How to give arguments for Read Csv As Dictionary in robot framework 如何根据机器人框架中的命令行 arguments 在机器人脚本中声明可选全局变量 - How to declare optional global variable in robot script depending upon command line arguments in robot framework Python Robot Framework将参数传递给函数 - Python Robot Framework Pass arguments to a function 传递时如何在机器人框架的嵌入式参数中删除双引号? - How to remove double-quotes in embedded arguments in robot framework while passing it? 如何使Robot Framework函数接受参数作为字符串而不是默认的Unicode类型 - How to make Robot Framework functions accept arguments as strings instead of the default unicode type
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM