Python 2.7 机器人框架中具有多个动作的If条件
我想在Robot框架中使用带有多个动作的If条件Python 2.7 机器人框架中具有多个动作的If条件,python-2.7,testing,automated-tests,robotframework,Python 2.7,Testing,Automated Tests,Robotframework,我想在Robot框架中使用带有多个动作的If条件 ${x} Set Variable 5 Run Keyword If ${x} == 5 ... ${Test1} = Set Variable MyName ... ${Test2} = Set Variable MyLastName ... Else ... ${Test1} = Set Variable MyAddress ... ${Test2} = Set Va
${x} Set Variable 5
Run Keyword If ${x} == 5
... ${Test1} = Set Variable MyName
... ${Test2} = Set Variable MyLastName
... Else
... ${Test1} = Set Variable MyAddress
... ${Test2} = Set Variable MyTelephone
但它不起作用
错误显示失败:找不到变量“${Test1}”。
您能告诉我如何在IF条件下使用多个操作吗?您可以使用“运行关键字”关键字在IF条件下执行多个操作
请点击以下链接:
您必须使用一个自定义关键字覆盖这两个操作,然后在时调用
运行关键字,或者在
时调用关键字设置变量两次,或者将此类逻辑写入python(jython…)库。请参阅以下关键字:
Run Keyword If ${x} == 5 Set Variable MyName
Run Keyword If ${x} == 1 Set Variable LastName
或
使用“运行关键字”时请注意“和”;还要确保使用了标签
Run Keyword If <condition1> <action1>
... ELSE IF <condition1>
... Run Keywords
... <action1>
... AND <action2>
Run关键字如果
... 否则如果
... 运行关键字
...
... 及
哦,天哪。RF人员真的认为这种语法比原始python语法好吗?为什么不直接使用python编写测试用例呢?依我看,那容易多了。
Run Keyword If <condition1> <action1>
... ELSE IF <condition1>
... Run Keywords
... <action1>
... AND <action2>
Set Test Variable ${temp} rxu
Run Keyword if '${temp}'=='rxu'
... Run Keywords
... Log To Console this is one
... AND Log To Console This is two
... ELSE Run Keyword Log To Console another block