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