IF ELSE Advance
Comparison Operators IF
*** Test Cases ***
006_01 Run keyword if
[Tags] if
${a} set variable 1
${b} set variable 2
run keyword if ${a} == ${b} log to console ${a} is equal to ${b}
@{list} create list a b c
log to console ${list}
run keyword if 'b' in ${list} log to console b is in list
Notice
ควรระวังเพราะ IF ไม่มี fail
IF ELSE
006_02 Run keyword if else
Keyword if to find company 3
006_03 Run keyword if else if
keyword if else another way 2
*** Keywords ***
Keyword if to find company
[Arguments] ${data}
run keyword if ${data}==1 log to console company 1
... ELSE IF ${data}==2 log to console company 2
... ELSE IF ${data}==3 log to console company 3
... ELSE log to console company out of range
keyword if else another way
[Arguments] ${data}
IF ${data}==1
log to console company 1
ELSE IF ${data}==2
log to console company 2
ELSE IF ${data}==3
log to console company 3
ELSE
log to console company out of range
END
For Loops
*** Test Cases ***
006_04 For loop
[Tags] for
FOR ${index} IN RANGE 5 50 5 #initial, max, step
log to console ${index}
END
For Loops with List
*** Test Cases ***
006_05 For loop with list
[Tags] for
@{list} create list a b c
FOR ${item} IN @{list}
log to console ${item}
END
FOR ${index} IN RANGE 0 len(${list})
log to console ${index+1}.${list[${index}]}
END
Nested For Loops
*** Test Cases ***
006_06 For Nested
[Tags] for nested
${str} set variable \n
FOR ${index} IN RANGE 5
FOR ${jndex} IN RANGE ${index} 5
${str} set variable ${str}*
END
${str} set variable ${str}\n
END
log to console ${str}