Robotframework for循环中关键字的Robot框架返回值为';没有通过
为了测试,我做了两个关键词。一般的想法是检查一系列对象是否存在某个字段、字段名和消息。如果字段或字段名不存在,则关键字必须返回forloop。关键字必须返回Robotframework for循环中关键字的Robot框架返回值为';没有通过,robotframework,Robotframework,为了测试,我做了两个关键词。一般的想法是检查一系列对象是否存在某个字段、字段名和消息。如果字段或字段名不存在,则关键字必须返回forloop。关键字必须返回${index}和${result}。当我运行这个测试并且它失败时,变量${results}显示为${result}=None,当测试通过时,它变成${result}=[3,u'PASS'] 我认为这与forloop中的${result}=有关 我尝试了Run关键字并返回,但没有成功,我有点困惑将${variables}放在哪里以及在哪里使用
${index}
和${result}
。当我运行这个测试并且它失败时,变量${results}显示为${result}=None
,当测试通过时,它变成${result}=[3,u'PASS']
我认为这与forloop中的${result}=
有关
我尝试了Run关键字并返回
,但没有成功,我有点困惑将${variables}
放在哪里以及在哪里使用它。
有人能帮我弄清楚吗
FORLOOP:
${index}= | set variable | 0
${result}= | Set Variable | not started
: FOR | ${value} | IN RANGE | ${index} | 15
\ ${resultaat}= |"other keyword" | ${index}
\ ${index}= | "keyword add 1 to index" | ${index}
\ Return From Keyword if | '${result}'=='PASS'
${testsuccess}= | Set Variable If | '${result}'=='PASS' | TEST GESLAAGD
“其他关键字”是:
[ARGS] ${index}
${index}= | set variable | ${index}
${check1}= <IS FIELD THERE>
${result}= | set variable if | ${check1}==False | FIELD NOT THERE
return from keyword if | ${check1}=False
${check2}= <HAS FIELD VALUE X>
${result}= | set variable if | ${check2}==False | WRONG VALUE
return from keyword if | ${check2}=False
${check3}= <IS MESSAGE X>
${result}= | set variable if | ${check3}==False | FAIL
${result}= | set variable if | ${check3}==True | PASS
[RETURN] ${index} ${result}
[ARGS]${index}
${index}=|集变量|${index}
${check1}=
${result}=|如果${check1}==False |字段不存在,则设置变量
如果${check1}=False,则从关键字返回
${check2}=
${result}=|如果${check2}==False |值错误,则设置变量
如果${check2}=False,则从关键字返回
${check3}=
${result}=|如果${check3}==False |失败,则设置变量
${result}=|如果${check3}==True |通过,则设置变量
[返回]${index}${result}
日志:
关键字='${result}'=='PASS'
FOR=
'${testsuccess}=None'
(但这是不正确的,因为条件已满足)如果在没有任何“Else”选项且条件未满足时,将值设置为None
,则设置变量。见文件:
因此,调整您的代码:
${result} | Set Variable If | ${check3}==False | FAIL
... | ${check3}==True | PASS
如文档示例所示。当我将${result}
放在返回关键字if
例如:
return from keyword if | ${check1}=False | ${result}
在for循环中尝试以下返回代码
*** Keywords ***
ReturnFromForLoop
FOR ${i} IN RANGE 1 5
Return From Keyword ${i}
END
ReturnFromForLoopWithIf
FOR ${i} IN RANGE 1 5
Return From Keyword If ${i}==2 ${i}
END
Thx,对于你的anwser,但是我正在创建这个测试,并且我使用好的路径。因此,结果总是会得到满足,因此不是我问题的解决方案。我将把这个添加到我的问题中。但是当我运行测试时,在关键字中设置了变量“${result}”=='PASS',但在FORLOOP中它是None,因此关键字中的值没有传递给FORLOOP