如何退出Robot Framework 4.0中ride 1.7.4.2中的嵌套for循环
我想在 ${port} == 3 时退出所有嵌套的 for 循环,但是无论我使用什么关键字,例如 '退出 for 循环' 或 '退出 for 循环 if ${port} == 3' ,它仍然会继续整个嵌套的 for 循环。同时,Robot Frameworkride 告诉我“break”是保留关键字,不能使用。 我的代码如下。
*** Test Cases ***
demo_01
${port} Set Variable 0
FOR ${i} IN RANGE 2
FOR ${j} IN RANGE 2
FOR ${k} IN RANGE 2
${port} Evaluate ${port} + 1
Log ${port}
IF ${port} == 3
Exit FOR Loop
END
END
END
END
结果就在这里 在此处输入图像描述
它刚刚退出内部 for 循环。 :(
所以我想知道如何退出 Robot Framework Ride 中的嵌套 for 循环。谢谢大家。 顺便说一句,这是我的 pip 列表
robotframework 4.1.2
robotframework-databaselibrary 1.2.4
robotframework-pythonlibcore 3.0.0
robotframework-ride 1.7.4.2
robotframework-selenium2library 3.0.0
robotframework-seleniumlibrary 3.0.0
robotframework-sshlibrary 3.8.0
,我的 python 版本是
C:\WINDOWS\system32>python -V
Python 3.7.9
谢谢
I wanna exit all nested for loops when ${port} == 3,however whatever keywords I use, such as
'Exit for loop' or 'Exit for loop if ${port} == 3' ,it will still continue the whole nested for loop. Meanwhile Robot Framework ride tells me that 'break' is a reserved keyword and can't be used.
My code is below.
*** Test Cases ***
demo_01
${port} Set Variable 0
FOR ${i} IN RANGE 2
FOR ${j} IN RANGE 2
FOR ${k} IN RANGE 2
${port} Evaluate ${port} + 1
Log ${port}
IF ${port} == 3
Exit FOR Loop
END
END
END
END
And the result is here
enter image description here
It just exited the inner for loop. :(
So I wanna know how to exit a nested for loop in Robot Framework Ride. Thank you all.
BTW here is my pip list below
robotframework 4.1.2
robotframework-databaselibrary 1.2.4
robotframework-pythonlibcore 3.0.0
robotframework-ride 1.7.4.2
robotframework-selenium2library 3.0.0
robotframework-seleniumlibrary 3.0.0
robotframework-sshlibrary 3.8.0
And my python version is
C:\WINDOWS\system32>python -V
Python 3.7.9
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
实现此目的的最简单方法是将封闭的 FOR 循环移至关键字中,然后在满足条件时从该循环返回。在你的情况下,它看起来像这样:
然后在测试中你只需调用上面的关键字:
Easiest way to achieve this is to move the enclosing FOR loops into a keyword and then return from it whenever a condition is met. In your case it will look like this:
Then in the test you just call the above keyword: