一、作get請求以前先安裝 Request庫,參考github上連接 :https://github.com/bulkan/robotframework-requests/#readmehtml
二、請求&響應使用moco來模擬服務器,可參考此篇文檔:Moco模擬服務器post&get請求 (二)git
三、get 請求流程以下:github
a.建立session服務器連接json
b.get請求把url和數據傳入api
c.判斷響應狀態碼是否爲200服務器
d.將響應的格式轉換爲json格式session
e.將json設置爲參數 字典的格式post
f.判斷斷言是否爲success & 200lua
四、可在pycharm上編輯,以下:url
*** Settings ***
Library RequestsLibrary
Library Collections
*** Test Case ***
testget
${payload} Create Dictionary eid=1
Create Session event http://127.0.0.1:8899/api
${r}= Get Request event /get_event_list params=${payload}
Should Be Equal As Strings ${r.status_code} 200
log ${r.json()}
${dict} Set variable ${r.json()}
#斷言結果
${msg} Get From Dictionary ${dict} msg
Should Be Equal ${msg} success
${sta} Get From Dictionary ${dict} status
${status} Evaluate str(200)
Should Be Equal ${sta} ${status}
五、運行結果以下:
六、運行結果report.html 以下: