Robot Framework的标签是一个简单而又强大的分类机制,功能以下:html
标签的几种方式:json
标签自己就是任意的文本,可是它们会被标签化:去除全部的空格,所有转为小写。若是一个用例被打上相同的标签屡次,仅保留第一个。标签可使用变量来建立,只要变量存在便可。跨域
建议使用标签来指定环境或用户信息等这类元数据。服务器
示例:session
*** Test Cases *** 登陆 [Tags] dltest 登陆app 15000000001 mima 161a3797c824bccd58c *** Keywords *** 登陆app [Arguments] ${username} ${password} ${jPushId} ${ssohost}=${EMPTY} log 开始登陆 ${data}= Create Dictionary loginName=${username} password=${password} jPushId=${jPushId} ${json}= Rest.post /rest/account/login ${data} form ${ssohost} Should Be True ${json["success"]} Rest.post [Arguments] ${uri} ${params} ${type}=form ${cur_host}=${EMPTY} #设置代理服务器,方便调试 ${proxy}= Create Dictionary http=http://1270.0.1:8888 ${host}= Set Variable ${EMPTY} : FOR ${tag} IN @{TEST TAGS} \ ${host}= Evaluate $hosts.get($tag,"") \ Run Keyword If "${host}"!="" Exit For Loop #建立session,跨域模式,不须要维护Session Run Keyword If "${cur_host}"!="" Create Session _session ${cur_host} ... ELSE Create Session _session ${host} #根据请求数据的类型设置header ${headers}= Run Keyword If "${type}"=="form" Create Dictionary Content-Type=application/x-www-form-urlencoded ... ELSE IF "${type}"=="json" Create Dictionary content-Type=application/json ${response}= Post Request _session ${uri} ${params} headers=${headers} Should Be Equal As Strings ${response.status_code} 200 log ${response.text} ${json}= Set Variable ${response.json()} [Return] ${json}
原文地址:https://www.cnblogs.com/chengchengla1990/p/8922090.htmlapp