Python 机器人无效 Return 来自关键字用法
Python Robot Invalid Return From Keyword usage
我正在尝试在 Robot 中执行以下代码并遇到以下错误。
我很难找出问题所在
${job_id}= Run Keyword And Return If "${cur_build}" != "<my_Build>" perform software upgrade ${wd} <device_name> <my_build>
下面是 xml 输出。
Success: 0 Failed : 0 Skipped : 0
Stop Delete</msg>
<status status="PASS" endtime="20160602 02:22:51.590" starttime="20160602 02:22:10.415"></status>
</kw>
<msg timestamp="20160602 02:22:51.591" level="INFO">Returning from the enclosing user keyword.</msg>
<status status="PASS" endtime="20160602 02:22:51.591" starttime="20160602 02:22:10.413"></status>
</kw>
<tags>
<tag>draft</tag>
<tag>upgrade</tag>
</tags>
<status status="FAIL" endtime="20160602 02:22:51.592" critical="yes" starttime="20160602 02:21:01.560">Invalid 'Return From Keyword' usage.</status>
编辑
所以我明白了 运行 Keyword 和 Return if 只能用在 Keywords 中,不能用在 Testcase 中。但是,我将如何在测试用例中执行以下操作
if <some_cond>:
${my_var}= <Keyword A>
Keyword B= ${my_var}
一种方法是添加定义新关键字,但是有没有办法在测试用例中执行此操作而不定义任何新关键字
请让我知道以下代码是否符合您的目的
*** Variables ***
@{list1} @{EMPTY}
@{list2} This is list list1
*** Test Cases ***
Conditional Test Case1
${flag}= Set Variable If @{list1}!=@{EMPTY} ${true} ${false}
${rc}= Run Keyword If ${flag}==${true} Log Multiple Values ${list1}
${rc}= Run Keyword Unless ${flag}==${false} Log Multiple Values ${rc}
Contitional Test Case2
${flag}= Evaluate len(${list2}) is not None
${rc}= Run Keyword If ${flag} == ${true} Log Multiple Values ${list2}
*** Keywords ***
Log Multiple Values
[Arguments] @{list_args}
[Documentation] This keyword logs its arguments and also returns them
Log Many @{list_args}
[Return] @{list_args}
我正在尝试在 Robot 中执行以下代码并遇到以下错误。 我很难找出问题所在
${job_id}= Run Keyword And Return If "${cur_build}" != "<my_Build>" perform software upgrade ${wd} <device_name> <my_build>
下面是 xml 输出。
Success: 0 Failed : 0 Skipped : 0
Stop Delete</msg>
<status status="PASS" endtime="20160602 02:22:51.590" starttime="20160602 02:22:10.415"></status>
</kw>
<msg timestamp="20160602 02:22:51.591" level="INFO">Returning from the enclosing user keyword.</msg>
<status status="PASS" endtime="20160602 02:22:51.591" starttime="20160602 02:22:10.413"></status>
</kw>
<tags>
<tag>draft</tag>
<tag>upgrade</tag>
</tags>
<status status="FAIL" endtime="20160602 02:22:51.592" critical="yes" starttime="20160602 02:21:01.560">Invalid 'Return From Keyword' usage.</status>
编辑
所以我明白了 运行 Keyword 和 Return if 只能用在 Keywords 中,不能用在 Testcase 中。但是,我将如何在测试用例中执行以下操作
if <some_cond>:
${my_var}= <Keyword A>
Keyword B= ${my_var}
一种方法是添加定义新关键字,但是有没有办法在测试用例中执行此操作而不定义任何新关键字
请让我知道以下代码是否符合您的目的
*** Variables ***
@{list1} @{EMPTY}
@{list2} This is list list1
*** Test Cases ***
Conditional Test Case1
${flag}= Set Variable If @{list1}!=@{EMPTY} ${true} ${false}
${rc}= Run Keyword If ${flag}==${true} Log Multiple Values ${list1}
${rc}= Run Keyword Unless ${flag}==${false} Log Multiple Values ${rc}
Contitional Test Case2
${flag}= Evaluate len(${list2}) is not None
${rc}= Run Keyword If ${flag} == ${true} Log Multiple Values ${list2}
*** Keywords ***
Log Multiple Values
[Arguments] @{list_args}
[Documentation] This keyword logs its arguments and also returns them
Log Many @{list_args}
[Return] @{list_args}