常用關鍵字:
should be true python表達式
1 ${res} set variable he 2 should be true '${res}' in 'hello' # 不加‘’號,代表變量 3 # python表達式,空格不能多於2個,$res只能應用在表達式中 4 should be true $res in 'hello' # 直接引用字符串本身 5 should be equal ${1*2} ${2} # {}內會根據python語法進行計算,這種會計算里面的值並轉換為int
1 定義變量 2 ${var1} set variable word #定義字面量 3 ${var2} convert to integer 2 # 定義整型 4 ${var3} convert to number 4.4 # 定義數字,可以是浮點數 5 log to console ${var1} 6 log to console ${var2} 7 log to console ${var3} 8 log to console ${4+3} # 7 數字變量 9 常用關鍵字 10 # should be true 注意點:數為python表達式,布爾類型,空格不能多於2個,變量前面加一個$ 11 # should be true 它的參數本身是python 表達式語句,RF會直接用python解釋器 的eval函數,來解釋這個參數表達式。 12 ${var1} set variable word 13 ${var2} convert to integer 2 # 定義整型 14 ${var3} convert to integer 3 # 定義整型 15 ${var4} create list #定義空列表 16 should be true 3==2 # 參數為python表達式,布爾類型,空格不能多於2個,變量前面加一個$ 17 should be true [] # 空列表為False 18 should contain hello he #第一個參數包含第二個參數 19 should start with hello h # 第一個參數以h開頭 20 should end with hello o # 第一個參數以o結尾 21 should be empty ${var4} # 判斷是否為空 22 23 判斷兩個對象是否相等 24 # should be equal ${var2} ${var3} 25 should be equal a a 26 should be equal as integers 10 010 #轉換成數字對象比較,結果是true 27 should be equal 10 010 #字符串對象比較,結果是False 28 should be equal as numbers 1.2 1.2 29 字符串比較 30 # $符號加變量,直接引用變量本身 31 ${var} set variable word 32 # 報錯Evaluating expression 'word == 'word'' failed: NameError: name 'word' is not defined 33 # should be true ${var} == 'word' 34 should be true '${var}' == 'word' #True 35 should be true $var == 'word' #True 36 整數比較 37 ${var} convert to integer 2 38 log to console ${2} # 2 39 should be true ${var} == ${2} 40 should be true $var == ${2} 41 should be true $var == 2
