有没有办法动态计算已将多少个Arguments传递给关键字?是否有办法打印像Log $ {Argument1},$ {Argument2}?这样的参数。例如有10个复选框可供选择。但在TC QA中只选择他/她作为参数发送给关键字的几个项目。因此,我们希望捕获所有参数列表以创建List并迭代它们以选择正确的复选框
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}
答案 0 :(得分:2)
Robot通过让[Arguments]
中的最后一项成为列表变量来支持可变数量的参数。
例如:
*** 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