其他分享
首页 > 其他分享> > 【RF】接口自动化demo

【RF】接口自动化demo

作者:互联网

*** Settings ***
Library           DateTime
Library           Selenium2Library
Library           RequestsLibrary

*** Test Cases ***
接口自动化
    ${headers}    Create Dictionary    Content-Type=application/x-www-form-urlencoded
    Create Session    base_url    https://novel.hctestedu.com/
    ${data}    Create Dictionary    username=18652030268    password=1234567890
    ${response}    Post Request    base_url    /user/login    data=${data}    headers=${headers}
    ${response_json}    Set Variable    ${response.json()}
    log    ${response.json()}
    ${headers1}    Create Dictionary    Cookie=Authorization=${response_json}[data][token]    Content-Type=application/x-www-form-urlencoded
    ${data1}    Create Dictionary    bookId=199    preContentId=945
    ${response1}    Post Request    base_url    user/addToBookShelf    data=${data1}    headers=${headers1}
    ${response1_json}    Set Variable    ${response1.json()}
    log    ${response1.json()}
    ${headers2}    Create Dictionary    Cookie=Authorization=${response_json}[data][token]
    ${data2}    Create Dictionary    curr=1    limit=10
    ${response2}    Get Request    base_url    user/listBookShelfByPage    data=${data2}    headers=${headers1}
    ${response2_json}    Set Variable    ${response2.json()}
    log    ${response2.json()}
    Should Be True    ${response2.json()}[data][list][0][bookId]==199

 

标签:response2,Dictionary,demo,Create,json,接口,RF,data,response
来源: https://www.cnblogs.com/hanyr/p/16463670.html