Robot Framework的标签是一个简单而又强大的分类机制,功能如下:
标签的几种方式:
标签本身就是任意的文本,但是它们会被标签化:去除所有的空格,全部转为小写。如果一个用例被打上相同的标签多次,仅保留第一个。标签可以使用变量来创建,只要变量存在即可。
建议使用标签来指定环境或用户信息等这类元数据。
示例:
*** 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.html
原文:https://www.cnblogs.com/dydxw/p/10537300.html