Robotframework 在Robot框架中有条件地递增一个变量
以下是我的脚本:Robotframework 在Robot框架中有条件地递增一个变量,robotframework,selenium2library,Robotframework,Selenium2library,以下是我的脚本: increment ${delCount}= Set Variable 0 :FOR ${loopIndex} INRANGE 0 8 \ Log ${loopIndex} \ ${delCount}= Run Keyword If '${loopIndex}'=='${3}' Run Keywords ${delCount+3} \ ... ELS
increment
${delCount}= Set Variable 0
:FOR ${loopIndex} INRANGE 0 8
\ Log ${loopIndex}
\ ${delCount}= Run Keyword If '${loopIndex}'=='${3}' Run Keywords ${delCount+3}
\ ... ELSE IF '${loopIndex}'=='${6}' Run Keywords ${delCount+6}
\ ... ELSE Sleep 1s
Log ${delCount}
我需要做的就是在条件满足时增加变量。怎么办?
我尝试了以下方法:
运行关键字评估${delCount}+${3}
运行关键字${delCount}=Set变量${delCount}+${3}
按如下方式运行关键字Evaluate${delCount}:
${delCount}= Set Variable 0
:FOR ${loopIndex} IN RANGE 0 8
\ Log ${loopIndex}
\ ${delCount}= Run Keyword If ${loopIndex} == 3 Evaluate ${loopIndex} + ${delCount}
\ ... ELSE IF ${loopIndex} == 6 Evaluate ${delCount} + 6
\ ... ELSE Sleep 1s
Log ${delCount}
当
loopIndex
不是3或6时,delCount
将设置为None
——因为这是Sleep 1s
的返回值。因此,在最后一个ELSE中,用Set变量${delCount}
替换它,这将保留它的当前值。因此,如果${loopIndex}不在(3,6)Sleep 1s,那么Sleep-\Run关键字还需要一个条件,它应该是好的。
${delCount} | Set Variable If | ${loopIndex} == 3 | ${delCount} + ${loopIndex} | ${delCount}
${delCount} | Set Variable If | ${loopIndex} == 6 | ${delCount} + 6 | ${delCount}