一 run keyword if 多条件判断
同时满足大于等于1小于7,使用and 即可
执行结果:满足要求!
#抽奖门槛-奖项等级 还原默认值
:FOR ${index} INRANGE 12
${n} Set Variable ${index}+1
click element //tbody/tr[${n}]/td[3]//*[@placeholder='请选择']
run keyword if ${index}>=1 and ${index}<7 Set Test Variable ${n} 2
run keyword if ${index}==7 Set Test Variable ${n} 3
run keyword if ${index}==8 Set Test Variable ${n} 4
run keyword if ${index}==9 Set Test Variable ${n} 5
run keyword if ${index}>=10 Set Test Variable ${n} 6
${n} Evaluate ${n}-1
sleep 0.3
click element //body/div[last()]//*[text()='${level[${n}]}'] #index=0,一等奖,1~6 二等奖
使用or 或符号替换and运行实践:
使用&替换and 的结果:
使用or替换and 的结果:
结论:“&”与“or”执行效果一样,与C知道返回的结果不一致
使用“|”替换“and” 的结果:
${index}=0,不满足条件结果同“and”;
${index}=1,满足条件结果同“and”;
${index}=2,不满足条件结果与“and”不同;
${index}=3,满足条件结果同“and”
${index}4、6同2, 5 同 3 偶数不满足奇数满足???
结论:“and”不能被符号替换
二 Set Variable if 替换run keyword if
Set Variable if替换run keyword if 实现相同功能:
#抽奖门槛-奖项等级 还原默认值
:FOR ${index} INRANGE 12
${n} Evaluate ${index}+1
click element //tbody/tr[${n}]/td[3]//*[@placeholder='请选择']
${n} Set Variable if ${index}>=1 and ${index}<7 2 ${n}
${n} Set Variable if ${index}==7 3 ${n}
${n} Set Variable if ${index}==8 4 ${n}
${n} Set Variable if ${index}==9 5 ${n}
${n} Set Variable if ${index}>=10 6 ${n}
${n} Evaluate ${n}-1
sleep 0.3
click element //body/div[last()]//*[text()='${level[${n}]}']