【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

 

posted @   hanyr  阅读(112)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
点击右上角即可分享
微信分享提示