“运行关键字如果"并设置一个变量 [英] "Run Keyword If" and setting a variable
本文介绍了“运行关键字如果"并设置一个变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
以下代码不起作用.如果条件为真,我想设置一个变量.
The following code doesn't work. I want to set a variable if a condition is true.
Run Keyword If ${MAC} == 110299160221421 ${device_serial}= set variable ${device_serial_1}
我得到错误:
No keyword with name '=' found
这是有效的,但不会改变变量.
This is working but doesn't change a variable.
Run Keyword If ${MAC} == 110299160221421 Log to console 111
推荐答案
Run keyword if
返回你正在运行的关键字的结果.因此,与任何其他关键字一样,如果要保存值,您可以在第一列中放置一个变量:
Run keyword if
returns the result of the keyword that you're running. So, like with any other keyword, you put a variable in the first column if you want to save the value:
${device_serial}= run keyword if ${MAC} == 110299160221421
... set variable ${device_serial_1}
在这种特定情况下,您可能希望使用 Set Variable If 而不是 Run Keyword If
I this specific case you might want to use Set Variable If instead of Run Keyword If
${device_serial}= set variable if ${MAC} == 110299160221421
... ${device_serial_1}
这篇关于“运行关键字如果"并设置一个变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文