test.robot:
FOR 循環要注意:
關鍵字:FOR IN END必須大寫,且END 需必寫,中間的空格都是兩個或兩個以上
如果用到IN RANGE 中間的空格是1個
*** Variables ***
@{list} '192.168.1.34' '3306'
&{dict1} name=Lara pwd=123456
*** Test Cases ***
case1---for循環中list的寫法1${list1}
FOR ${i} IN ${list}
log to console ${i}
END
case2---for循環中list的寫法2@{list1}
FOR ${i} IN @{list}
log to console ${i}
END
case3---for循環中dict的寫法1${dict1}
FOR ${i} IN ${dict1}
log to console ${i}
END
case4---for循環中dict的寫法2&{dict1}
FOR ${i} IN &{dict1}
log to console ${i}
END
case5---for循環中dict的寫法3@{dict1}
FOR ${i} IN @{dict1}
log to console ${i}
END
執行結果:
正常情況,for循環,遍歷出所有的元素。所以:
列表:@{list1} 取出列表中每一個值 ${list1} 會取出一個整體
對於字典中@dict1 寫法有待研究