RF - 完整用例展示

Posted 小猪爱jshell

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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

  

以上是关于RF - 完整用例展示的主要内容,如果未能解决你的问题,请参考以下文章

RF目录结构、执行参数、用例标签

RF之目录结构、执行参数、用例标签

VSCode自定义代码片段——git命令操作一个完整流程

VSCode自定义代码片段15——git命令操作一个完整流程

VSCode自定义代码片段15——git命令操作一个完整流程

RF快捷键