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