如果回傳結果為TRUE或FALSE
Problem
最近在寫條件判斷時,看到類似下面寫法:
Run Keyword If | '${ret}' == 'TRUE' | xxx於是就在想,應該可以寫成這樣吧:
Run Keyword If | ${ret} | xxx所以我分享一下要怎麼調整。
How to?
最重要的就是把${ret}轉為Boolean,它是ignore case sensitive:
${ret} | Convert to Boolean | ${ret}要做判斷時,這幾種寫法都是可以使用的:
Run Keyword If | ${ret} | xxx Run Keyword If | not ${ret} | xxx Run Keyword If | ${ret} == ${true} | xxx Run Keyword If | ${ret} != ${true} | xxx Run Keyword If | '${ret}' == 'True' | xxx假如你是把原本的keyword從string要轉為boolean,你的client判斷如果是用字串,要改為True或False。
Reference