【发布时间】:2016-10-01 18:46:52
【问题描述】:
我正在尝试在 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>
编辑
所以我知道 Run Keyword 和 Return if 只能在关键字中使用,而不能在测试用例中使用。但是那我将如何在测试用例中做类似下面的事情
if <some_cond>:
${my_var}= <Keyword A>
Keyword B= ${my_var}
一种方法是添加定义新关键字 with 但有没有一种方法可以在测试用例中做到这一点而不定义 anynew 关键字
【问题讨论】:
-
您的问题不够清楚,请提供更多信息,例如用于解释 .robot 文件的代码。
-
您发布的代码行必须在用户关键字内。它不能在测试用例、设置或拆卸中。见robotframework.org/robotframework/latest/libraries/…
-
@ombre42 好的,我现在明白了。
-
现在解决了吗?您是在问“如何根据条件运行关键字并存储返回值?”而不定义新关键字?
-
@Waman 我现在明白为什么我得到了,所以我的问题仍然存在,但是问题陈述现在已经改变,现在就是你提到的。
标签: python robotframework