标签:cas ret this random pat att ext nec efault
1. Set Variable
定义:Returns the given values which can then be assigned to a variables.
示例1:
${a} Set Variable 50
示例2:
${traffic_in_xpath}= Set Variable xpath=//table[@id=‘blocked_services_table‘]//td[text()=‘${service_name}‘]/parent::tr/td[4] ${traffic_in_status} Get Element Attribute ${browser} ${traffic_in_xpath}//input[@type=‘checkbox‘]@checked ${traffic_in_checked}= Run Keyword If ‘${traffic_in_status}‘==‘None‘ Set Variable false ELSE Set Variable true
2. Create List
定义:Returns a list containing given items.
示例1:
@{list} Create List a b c
示例2:
: FOR ${index} IN RANGE 5
\ # Verify the connection status \ ${is_pass} Run Keyword And Ignore Error Should Match Regexp ${result} Connection.*succeeded! \ # Verify the result \ Run Keyword If ‘@{is_pass}[0]‘==‘${expected_status}‘ Exit For Loop
3. Evaluate
定义:Evaluates the given expression in Python and returns the results.
示例1:
generate random ip address [Arguments] ${start} ${stop} [Documentation] generate random IP address, such as 192.168.1.xxx [Return] ${r} ${random} Evaluate random.randint(${start},${stop}) random ${r} Set Variable 192.168.1.${random}
示例2:类型转换
${a} Evaluate int(4) ${b} Evaluate int(5)
示例3:结果运算
${ns} = Create Dictionary x=${4} y=${2} ${result}= Evaluate x*10 + y namespace=${ns} Result: ${ns} = {‘x‘: 4, ‘y‘: 2} ${result} = 42
4. Get Variable Value
定义:
Returns variable value or default
if the variable does not exist.
示例1:
*** Test Cases *** test case1 - Run Keyword If ${a} Set Variable 50 Run Keyword If ${a}>=90 Log 优秀 ... ELSE IF ${a}>=70 Log 良好 ... ELSE IF ${a}>=60 Log 及格 ... ELSE Log 不及格 ${a_a} Get Variable Value ${a} log ${a_a} test case2 - Run Keyword Ignore Error @{CAPTAINS} Create List Picard Kirk Archer Run Keyword And Ignore Error Should Be Empty ${CAPTAINS} Log Reached this point despite of error @{list} Get Variable Value @{CAPTAINS} log ${list} 运行结果: Starting test: Rf Test.Helloworld.test case1 - Run Keyword If 20180519 14:34:58.590 : INFO : ${a} = 50 20180519 14:34:58.592 : INFO : 不及格 20180519 14:34:58.594 : INFO : ${a_a} = 50 20180519 14:34:58.594 : INFO : 50 Ending test: Rf Test.Helloworld.test case1 - Run Keyword If Starting test: Rf Test.Helloworld.test case2 - Run Keyword Ignore Error 20180519 14:34:58.597 : INFO : @{CAPTAINS} = [ Picard | Kirk | Archer ] 20180519 14:34:58.598 : INFO : Length is 3 20180519 14:34:58.599 : FAIL : ‘[‘Picard‘, ‘Kirk‘, ‘Archer‘]‘ should be empty. 20180519 14:34:58.601 : INFO : Reached this point despite of error 20180519 14:34:58.602 : INFO : @{list} = [ Picard | Kirk | Archer ] 20180519 14:34:58.603 : INFO : [‘Picard‘, ‘Kirk‘, ‘Archer‘] Ending test: Rf Test.Helloworld.test case2 - Run Keyword Ignore Error
标签:cas ret this random pat att ext nec efault
原文地址:https://www.cnblogs.com/studyddup0212/p/9060295.html