zoukankan      html  css  js  c++  java
  • 简例s

    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
    

      

  • 相关阅读:
    中国身份证号码验证
    防止盗链下载问题
    Microsoft .NET Pet Shop 4 架构与技术分析
    常用操作封装类
    ASP.NET 2.0页面框架的几处变化
    普通字符串与HTML相互转换的小经验
    HttpWebRequest实现读取天气预报信息
    事务回滚 c# .net代码
    CAJViewer,AdobeReader等阅读器实现金山词霸屏幕取词功能
    01背包问题动态规划详解
  • 原文地址:https://www.cnblogs.com/studyddup0212/p/9060295.html
Copyright © 2011-2022 走看看