码迷,mamicode.com
首页 > 其他好文 > 详细

RF - 完整用例展示

时间:2018-05-19 16:59:16      阅读:212      评论:0      收藏:0      [点我收藏+]

标签:nta   python   setting   nts   arc   pytho   完整   return   text   

将重复性动作进行封装为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 - 完整用例展示

标签:nta   python   setting   nts   arc   pytho   完整   return   text   

原文地址:https://www.cnblogs.com/studyddup0212/p/9060484.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!