美文网首页
robotframework 关于上传附件接口

robotframework 关于上传附件接口

作者: 李鸭还有礼了 | 来源:发表于2019-11-13 22:06 被阅读0次

    在一般的接口测试过程中,我们往往会遇到附件上传的接口,在robotframework中,我们往往采用evaluate关键字来处理此类接口:

    demo_file
        Create Session    api     http://127.0.0.1
        ${file}    Evaluate    open(r"D:\\pic\\21325098165.jpg",'rb')
        &{tepp}    Create Dictionary    file=${file}
        ${resp}    post request    api    /host/web/worker/v1/upload    files=&{tepp}    headers=${headers}
        ${content}    To Json    ${resp.content}
        ${msg}    Set Variable    ${content['msg']} 
    

    在上述的描述的过程中,先evaluate关键字调用open的方法将需要上传的文件打开,在进行字典的创建,在后续的过程中将创建的字典传到post request 关键字的 file参数中。

    相关文章

      网友评论

          本文标题:robotframework 关于上传附件接口

          本文链接:https://www.haomeiwen.com/subject/grakictx.html