美文网首页
httprunner3.0 上传文件

httprunner3.0 上传文件

作者: gz_tester | 来源:发表于2021-04-25 15:41 被阅读0次

对于上传文件类型的测试场景,HttpRunner 集成 requests_toolbelt 实现了上传功能。

使用内置 upload 关键字,可轻松实现上传功能

只有一个字段的时候

config:
    name: ×××
    variables:
        username: ${super_admin()}
    base_url: ${base_url()}
    
teststeps:
-   name: ×××
    request:
        headers:
          Content-Type: "multipart/form-data"
        method: POST
        upload:
          file: "testdata/1.docx"
        url: ×××
    validate:
    -   eq:
        - status_code
        - 200

有多个字段的时候

config:
    name: ×××
    variables:
        username: ${super_admin()}
    base_url: ${base_url()}

teststeps:

    -   name: ×××
        request:
            url: ×××
            method: POST
            upload:
                file: "testdata/1_01_在职证明_通用版_正式员工.doc"
                bizid: "notStand"
                signTypeNo: "3"
        validate:
            -   eq: [status_code, 200]
            -   eq: [json.code, "200"]
            -   eq: [json.message, "文件上传成功"]

相关文章

网友评论

      本文标题:httprunner3.0 上传文件

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