zoukankan      html  css  js  c++  java
  • RF

    将重复性动作进行封装为keyword,在测试用例中调用keyword。

    *** Settings ***
    Documentation     Simple example using SeleniumLibrary.
    Library           SeleniumLibrary
    
    
    *** Variables ***
    ${URL}            https://www.baidu.com
    ${BROWSER}        Chrome
    
    
    *** Test Cases ***
    case1
        Open Browser    ${URL}    ${BROWSER}
        ${title}    Baidu Search    robot framework
        should contain    ${title}    robot framework_百度搜索
        close browser
    
    case2
        Open Browser    ${URL}    ${BROWSER}
        ${title}    Baidu Search    selenium
        should contain    ${title}    selenium_百度搜索
        close browser
    
    
    *** Keywords ***
    Baidu Search
        [Arguments]    ${search_key}
        Input text    id:kw    ${search_key}
        click button    id:su
        Evaluate    time.sleep(2)    time
        ${title}    Get Title
        [Return]    ${title}
    

      

    运行结果:

    Starting test: Rf Test.Helloworld.case1
    20180519 15:29:25.486 : INFO : Opening browser 'Chrome' to base url 'https://www.baidu.com'.
    20180519 15:29:31.008 : INFO : Typing text 'robot framework' into text field 'id:kw'.
    20180519 15:29:31.349 : INFO : Clicking button 'id:su'.
    20180519 15:29:33.639 : INFO : ${title} = robot framework_百度搜索
    20180519 15:29:33.641 : INFO : ${title} = robot framework_百度搜索
    Ending test: Rf Test.Helloworld.case1
    
    Starting test: Rf Test.Helloworld.case2
    20180519 15:29:36.811 : INFO : Opening browser 'Chrome' to base url 'https://www.baidu.com'.
    20180519 15:29:42.303 : INFO : Typing text 'selenium' into text field 'id:kw'.
    20180519 15:29:42.537 : INFO : Clicking button 'id:su'.
    20180519 15:29:44.688 : INFO : ${title} = selenium_百度搜索
    20180519 15:29:44.691 : INFO : ${title} = selenium_百度搜索
    Ending test: Rf Test.Helloworld.case2
    

      

  • 相关阅读:
    Codeforces Round 546 (Div. 2)
    Codeforces Round 545 (Div. 2)
    Codeforces Round 544(Div. 3)
    牛客小白月赛12
    Codeforces Round 261(Div. 2)
    Codeforces Round 260(Div. 2)
    Codeforces Round 259(Div. 2)
    Codeforces Round 258(Div. 2)
    Codeforces Round 257 (Div. 2)
    《A First Course in Probability》-chaper5-连续型随机变量-随机变量函数的分布
  • 原文地址:https://www.cnblogs.com/studyddup0212/p/9060484.html
Copyright © 2011-2022 走看看