精华内容
下载资源
问答
  • data_login.json参数化json

    2020-08-12 21:00:17
    data_login.json [ {"case_name":"登录成功", "request_body": {"mobile": "13800000002","password": "123456"}, "success": true, "code": 10000, "message":"操作成功", "status_code": 200}, {"case_name...

    data_login.json

    [
      {"case_name":"登录成功",
        "request_body": {"mobile": "13800000002","password": "123456"},
        "success": true,
        "code": 10000,
        "message":"操作成功",
        "status_code": 200},
      {"case_name":"手机号码未注册","request_body": {"mobile": "14000000002","password": "123456"}, "success": false,"code": 20001,"message":"用户名或密码错误","status_code": 200},
      {"case_name":"手机号码长度超过11位","request_body": {"mobile": "14000000022102","password": "123456"}, "success": false,"code": 20001,"message":"用户名或密码错误","status_code": 200},
      {"case_name":"手机号码长度位数不够","request_body": {"mobile": "122","password": "123456"}, "success": false,"code": 20001,"message":"用户名或密码错误","status_code": 200},
      {"case_name":"手机号码为空","request_body": {"mobile": "","password": "123456"}, "success": false,"code": 20001,"message":"用户名或密码错误","status_code": 200},
      {"case_name":"密码错误","request_body": {"mobile": "13800000002","password": "error"}, "success": false,"code": 20001,"message":"用户名或密码错误","status_code": 200},
      {"case_name":"密码长度不够","request_body": {"mobile": "13800000002","password": "1"}, "success": false,"code": 20001,"message":"用户名或密码错误","status_code": 200},
      {"case_name":"密码中有特殊字符","request_body": {"mobile": "13800000002","password": "[!@#$%^&*()]"}, "success": false,"code": 20001,"message":"用户名或密码错误","status_code": 200},
      {"case_name":"少参-缺少mobile","request_body": {"password": "123456"}, "success": false,"code": 20001,"message":"用户名或密码错误","status_code": 200},
      {"case_name":"少参-缺少password","request_body": {"mobile": "13800000002"}, "success": false,"code": 20001,"message":"用户名或密码错误","status_code": 200},
      {"case_name":"无参-传递大括号","request_body": {}, "success": false,"code": 20001,"message":"用户名或密码错误","status_code": 200},
      {"case_name":"无参-传递null","request_body": null, "success": false,"code": 99999,"message":"抱歉,系统繁忙,请稍后重试","status_code": 200},
      {"case_name":"错误参数","request_body": {"mboile": "13800000002","password": "123456"}, "success": false,"code": 20001,"message":"用户名或密码错误","status_code": 200},
      {"case_name":"多参","request_body": {"mobile": "13800000002","password": "123456","more": "111"}, "success": true,"code": 10000,"message":"操作成功","status_code": 200}
    ]
    
    展开全文
  • data_employee.json { "add_emp": { "request_body": { "username":"比卡丘去吧", "mobile":"15856732125", "timeOfEntry":"2020-07-07", "formOfEmployment":1, "workNumber":"12312313", "depart

    data_employee.json

    {
      "add_emp": {
        "request_body": {
                "username":"比卡丘去吧",
                "mobile":"15856732125",
                "timeOfEntry":"2020-07-07",
                "formOfEmployment":1,
                "workNumber":"12312313",
                "departmentName":"销售",
                "departmentId":"1266699057968001024",
                "correctionTime":"2020-07-28T16:00:00.000Z"
            },
        "success": true,
        "code": 10000,
        "message": "操作成功",
        "status_code": 200
      },
      "query_emp": {
        "success": true,
        "code": 10000,
        "message": "操作成功",
        "status_code": 200
      },
      "modify_emp": {
        "request_body": {"username":"葫芦娃"},
        "success": true,
        "code": 10000,
        "message": "操作成功",
        "status_code": 200
      },
      "delete_emp": {
        "success": true,
        "code": 10000,
        "message": "操作成功",
        "status_code": 200
      }
    }
    
    展开全文
  • 一、post请求有两种方法传json参数:1.传json参数(自动转 json )2.传data参数(需 json 转换)代码参考:payload = {"Jodie":"How are you ?","python":123,"requests":True}url = "http://httpbin.org/post"#第一种...

    一、post请求有两种方法传json参数:

    1.传json参数(自动转 json )

    2.传data参数(需 json 转换)

    代码参考:

    payload = {

    "Jodie":"How are you ?",

    "python":123,

    "requests":True

    }

    url = "http://httpbin.org/post"

    #第一种直接传 json 参数(推荐使用这种)

    r1 = requests.post(url, json=payload) # json 参数直接自动传 json

    print(r1.text)

    print("---------------------------------------")

    #第二种传 data 参数,需要转 json

    r2 = requests.post(url, data=json.dumps(payload)) #传 data 参数就需要传 json

    print(r2.text)

    运行后的打印结果:

    F:\test-req-py\venv\Scripts\python.exe F:/test-req-py/day3/t3.py

    {

    "args": {},

    "data": "{\"Jodie\": \"How are you ?\", \"python\": 123, \"requests\": true}",

    "files": {},

    "form": {},

    "headers": {

    "Accept": "*/*",

    "Accept-Encoding": "gzip, deflate",

    "Content-Length": "59",

    "Content-Type": "application/json",

    "Host": "httpbin.org",

    "User-Agent": "python-requests/2.21.0"

    },

    "json": {

    "Jodie": "How are you ?",

    "python": 123,

    "requests": true

    },

    "origin": "223.104.210.143, 223.104.210.143",

    "url": "https://httpbin.org/post"

    }

    ---------------------------------------

    {

    "args": {},

    "data": "{\"Jodie\": \"How are you ?\", \"python\": 123, \"requests\": true}",

    "files": {},

    "form": {},

    "headers": {

    "Accept": "*/*",

    "Accept-Encoding": "gzip, deflate",

    "Content-Length": "59",

    "Host": "httpbin.org",

    "User-Agent": "python-requests/2.21.0"

    },

    "json": {

    "Jodie": "How are you ?",

    "python": 123,

    "requests": true

    },

    "origin": "223.104.210.143, 223.104.210.143",

    "url": "https://httpbin.org/post"

    }

    Process finished with exit code 0

    二、快递查询案例

    1.例如打开快递网:http://www.kuaidi.com/,搜索 75135471609813 单号,判断它的状态是不是已签收

    实操中原本的理想代码,实际没不通:

    #coding:utf-8

    import requests

    import json

    url = "http://www.kuaidi.com/index-ajaxselectcourierinfo-75135471609813-zhongtong.html"

    h = {

    "Connection": "keep-alive",

    "User-Agent": "Mozilla/5.0 (Windows NT 6.1; Win64; x64) "

    "AppleWebKit/537.36 (KHTML, like Gecko) "

    "Chrome/70.0.3538.110 Safari/537.36",

    "Content-Type":"application/x-www-form-urlencoded; charset=UTF-8",

    "Referer":"http://www.kuaidi.com/",

    "Cookie":"lang=zh-cn; theme=default; sid=ngr6ji5prpj85cmj7lncnccap7; "

    "UM_distinctid=169c4b016739f-069c297f9ff0e7-3a3a5d0c-100200-169c4b016752ec; "

    "CNZZDATA1254194234=2076602214-1553782570-%7C1553782570"

    }

    d= {

    "geetest_challenge":"af4536ec53cb7935a0326b1c4031f1a0jt",

    "geetest_validate":"49aec4801b8b9a125fa1473876b2f036",

    "geetest_seccode":"49aec4801b8b9a125fa1473876b2f036|jordan"

    }

    s = requests.session()

    r = s.post(url, headers=h, data=d, verify=False)

    result = r.json()

    print(type(result))

    print(result["company"])

    data = result["data"]

    print(data)

    print(data[0])

    get_result = data[0]['context']

    print(get_result)

    if u"签收" in get_result:

    print("快递单已签收成功")

    else:

    print("未签收")

    运行后 print(result["company"]) 返回的结果为 None ,后面的返回错误:

    一 一排查没找到原因,直到在 fiddle 中用 Composer 发送请求后,查看返回后的结果才明白,具体如下:

    1.用composer发送请求(将之前发送成功的请求拖至此处)

    2.查看返回的结果

    实际上这个接口在fiddler上都没有跑通,用如下代码验证:

    #coding:utf-8

    import requests

    import json

    # import urllib3

    # urllib3.disable_warnings()

    url = "http://www.kuaidi.com/index-ajaxselectcourierinfo-75135471609813-zhongtong.html"

    h = {

    "Connection": "keep-alive",

    "User-Agent": "Mozilla/5.0 (Windows NT 6.1; Win64; x64) "

    "AppleWebKit/537.36 (KHTML, like Gecko) "

    "Chrome/70.0.3538.110 Safari/537.36",

    "Content-Type":"application/x-www-form-urlencoded; charset=UTF-8",

    "Referer":"http://www.kuaidi.com/",

    "Cookie":"lang=zh-cn; theme=default; sid=ngr6ji5prpj85cmj7lncnccap7; "

    "UM_distinctid=169c4b016739f-069c297f9ff0e7-3a3a5d0c-100200-169c4b016752ec; "

    "CNZZDATA1254194234=2076602214-1553782570-%7C1553782570"

    }

    d= {

    "geetest_challenge":"af4536ec53cb7935a0326b1c4031f1a0jt",

    "geetest_validate":"49aec4801b8b9a125fa1473876b2f036",

    "geetest_seccode":"49aec4801b8b9a125fa1473876b2f036|jordan"

    }

    s = requests.session()

    r = s.post(url, headers=h, data=d, verify=False)

    result = r.json()

    print(type(result))

    print(result["company"])

    print(result["companytype"])

    print(result["reason"])

    返回的结果如下:

    与 fiddler 返回的结果一致

    所以是这个接口再次请求的时候就出现问题了,有兴趣可以再换一个近期的快递单号试试

    本次实操收获:以后在做接口测试的时候尽量先在fiddler 的 Compser上请求一次,看下能不能先跑通,以免出现问题的时候花大量的时间来排查!!

    展开全文
  • 一、post请求有两种方法传json参数: 1.传json参数(自动转 json ) 2.传data参数(需 json 转换) 代码参考: payload = { "Jodie":"How are you ?", "python":123, "requests":True ...

    一、post请求有两种方法传json参数:

    • 1.传json参数(自动转 json )
    • 2.传data参数(需 json 转换)

     

    代码参考:

    payload = {
              "Jodie":"How are you ?",
              "python":123,
              "requests":True
              }
    url = "http://httpbin.org/post"
    
    #第一种直接传 json 参数(推荐使用这种)
    r1 = requests.post(url, json=payload)               # json 参数直接自动传 json
    print(r1.text)
    
    print("---------------------------------------")
    #第二种传 data 参数,需要转 json
    r2 = requests.post(url, data=json.dumps(payload))    #传 data 参数就需要传 json
    print(r2.text)

     

    运行后的打印结果:

    F:\test-req-py\venv\Scripts\python.exe F:/test-req-py/day3/t3.py
    {
    "args": {},
    "data": "{\"Jodie\": \"How are you ?\", \"python\": 123, \"requests\": true}",
    "files": {},
    "form": {},
    "headers": {
    "Accept": "*/*",
    "Accept-Encoding": "gzip, deflate",
    "Content-Length": "59",
    "Content-Type": "application/json",
    "Host": "httpbin.org",
    "User-Agent": "python-requests/2.21.0"
    },
    "json": {
    "Jodie": "How are you ?",
    "python": 123,
    "requests": true
    },
    "origin": "223.104.210.143, 223.104.210.143",
    "url": "https://httpbin.org/post"
    }

    ---------------------------------------
    {
    "args": {},
    "data": "{\"Jodie\": \"How are you ?\", \"python\": 123, \"requests\": true}",
    "files": {},
    "form": {},
    "headers": {
    "Accept": "*/*",
    "Accept-Encoding": "gzip, deflate",
    "Content-Length": "59",
    "Host": "httpbin.org",
    "User-Agent": "python-requests/2.21.0"
    },
    "json": {
    "Jodie": "How are you ?",
    "python": 123,
    "requests": true
    },
    "origin": "223.104.210.143, 223.104.210.143",
    "url": "https://httpbin.org/post"
    }


    Process finished with exit code 0

     

    二、快递查询案例

    1.例如打开快递网:http://www.kuaidi.com/,搜索 75135471609813 单号,判断它的状态是不是已签收

     

    实操中原本的理想代码,实际没不通:

    #coding:utf-8
    import requests
    import json
    url = "http://www.kuaidi.com/index-ajaxselectcourierinfo-75135471609813-zhongtong.html"
    h = {
        "Connection": "keep-alive",
        "User-Agent": "Mozilla/5.0 (Windows NT 6.1; Win64; x64) "
                      "AppleWebKit/537.36 (KHTML, like Gecko) "
                      "Chrome/70.0.3538.110 Safari/537.36",
        "Content-Type":"application/x-www-form-urlencoded; charset=UTF-8",
        "Referer":"http://www.kuaidi.com/",
        "Cookie":"lang=zh-cn; theme=default; sid=ngr6ji5prpj85cmj7lncnccap7; "
                 "UM_distinctid=169c4b016739f-069c297f9ff0e7-3a3a5d0c-100200-169c4b016752ec; "
                 "CNZZDATA1254194234=2076602214-1553782570-%7C1553782570"
        }
    
    d= {
        "geetest_challenge":"af4536ec53cb7935a0326b1c4031f1a0jt",
        "geetest_validate":"49aec4801b8b9a125fa1473876b2f036",
        "geetest_seccode":"49aec4801b8b9a125fa1473876b2f036|jordan"
        }
    s = requests.session()
    r = s.post(url, headers=h, data=d, verify=False)
    result = r.json()
    print(type(result))
    print(result["company"])
    data = result["data"]
    print(data)
    print(data[0])
    get_result = data[0]['context']
    print(get_result)
    if u"签收" in get_result:
        print("快递单已签收成功")
    else:
        print("未签收")

    运行后 print(result["company"]) 返回的结果为 None ,后面的返回错误:

     

    一 一排查没找到原因,直到在 fiddle 中用 Composer 发送请求后,查看返回后的结果才明白,具体如下:

    1.用composer发送请求(将之前发送成功的请求拖至此处)

    2.查看返回的结果

     

    实际上这个接口在fiddler上都没有跑通,用如下代码验证:

    #coding:utf-8
    import requests
    import json
    # import urllib3
    # urllib3.disable_warnings()
    url = "http://www.kuaidi.com/index-ajaxselectcourierinfo-75135471609813-zhongtong.html"
    h = {
        "Connection": "keep-alive",
        "User-Agent": "Mozilla/5.0 (Windows NT 6.1; Win64; x64) "
                      "AppleWebKit/537.36 (KHTML, like Gecko) "
                      "Chrome/70.0.3538.110 Safari/537.36",
        "Content-Type":"application/x-www-form-urlencoded; charset=UTF-8",
        "Referer":"http://www.kuaidi.com/",
        "Cookie":"lang=zh-cn; theme=default; sid=ngr6ji5prpj85cmj7lncnccap7; "
                 "UM_distinctid=169c4b016739f-069c297f9ff0e7-3a3a5d0c-100200-169c4b016752ec; "
                 "CNZZDATA1254194234=2076602214-1553782570-%7C1553782570"
        }
    
    d= {
        "geetest_challenge":"af4536ec53cb7935a0326b1c4031f1a0jt",
        "geetest_validate":"49aec4801b8b9a125fa1473876b2f036",
        "geetest_seccode":"49aec4801b8b9a125fa1473876b2f036|jordan"
        }
    s = requests.session()
    r = s.post(url, headers=h, data=d, verify=False)
    result = r.json()
    print(type(result))
    print(result["company"])
    print(result["companytype"])
    print(result["reason"])
    

     

    返回的结果如下:

    与 fiddler 返回的结果一致

    所以是这个接口再次请求的时候就出现问题了,有兴趣可以再换一个近期的快递单号试试

     

    本次实操收获:以后在做接口测试的时候尽量先在fiddler 的 Compser上请求一次,看下能不能先跑通,以免出现问题的时候花大量的时间来排查!!

     

    转载于:https://www.cnblogs.com/JodieRao/p/10618086.html

    展开全文
  • 这个时候我们就需要 进行参数序列 很简单就两句话 如下图 我们看 JSON,stringify(json类型的数据) 这样就可以让数据编程json了 并且 我们需要需要设置请求的内容类型是 application/json 也就是 上面标注的...
  • 在一个项目中用到了SignalR,发现在DateTime的Json序列和反序列的时候,它的格式中的时区是未指定的,DateTimeKind.Unspecified 如果不做任何处理,SignalR所序列一个日期2018-11-27T14:04:00+08:00(北京时间...
  • jmeter实例(json断言+参数化),检查点详细介绍、正则表达式使用方法、JSON断言、CSV参数化
  • #### Go 命令行参数,JSON 序列,反序列这一节来学习一下Go 如果解析命令行参数,以及JSON 的序列及反序列; 命令行参数对于熟悉Linux 的同学来说比较清楚,如: ls -a , wc -l ... 其中,-a, -l 都是命令行参数; ...
  • 例如在POST请求中另一个经常用到的参数json,如果请求头中Content-Type对应的value值是application/json,入参一般是data类型,那么我们就可以使用json序列入参方式进行尝试仔Python中编写该请求的代码,...
  • jmeter之json数据参数化 断言等

    千次阅读 2018-12-25 11:54:28
    本文详细介绍如何进行 JMeter 的 json 测试提交,以及如何将其参数化。Step 1 http json 请求采样器的录制  这个工具很多,可以使用 JMeter 代理录制,也可以使用 Badboy。 Step 2 为该采样器添加 HTTP 信息管理...
  • (2015-04-10 16:10:41) 转载▼ 标签: loadrunner json 参数化 web_custom_request 分类: 性能测试 ...因为Json使用{}进行配对,但是Loadrunner使用{}进行参数化,存...
  • 今天是刘小爱自学Java的第167天。感谢你的观看,谢谢你。学习计划安排如下:在导入数据到索引库的过程使用到了一个工具类JsonUtils,在...而Java中数据的体现方法无外乎就是对象,所以会涉及到Json字符串的序列与...
  • jmeter之json数据参数化、断言设置

    千次阅读 2017-12-11 10:03:18
    本文详细介绍如何进行 JMeter 的 json 测试提交,以及如何将其参数化。 Step 1 http json 请求采样器的录制  这个工具很多,可以使用 JMeter 代理录制,也可以使用 Badboy。 Step 2 为该采样器添加 HTTP ...
  • post请求——传json参数

    千次阅读 2020-04-08 11:31:13
    在做接口自动测试的时候,遇到了一个带有json参数的post请求接口,由于请求的参数设置不对,导致一直返回415之后查询了httpclient对json参数的相关信息,终于完成了对该接口的调试,以下为实践步骤: 1.将json...
  • <?... //error_reporting(E_ALL^E_NOTICE^E_WARNING); class dbsql{ function conn(){ mysql_connect("root","root",''); mysql_query("set names utf8");... mysql_select_db('bdm295719610_db');...
  • html代码 <form id="myform"> user:<input type="text" name="username"><br> age:<input type="text" name="age" ><...input type="checkbox" name="hobby" value...
  • 什么是JSON? 概念:一种轻量级数据交换格式;后缀名 .json 提示: 接口测试一般使用JSON为接口传递数据规范格式,所以我们有必要对如何获取JSON数据做个了解;...2、使用JSON实现三角形案例参数化-操作...
  • 这里写自定义目录标题JMeter参数化使用json进行post请求如何插入一段漂亮的代码片生成一个适合你的列表创建一个表格设定内容居中、居左、居右SmartyPants创建一个自定义列表如何创建一个注脚注释也是必不可少的KaTeX...
  • 因工作需要,最近开始学习Jmeter,get到新的知识点记录下来,分享给大家,如有错误欢迎...2.有时候我们会遇到参数传递的是一个json串,应用场景:jmeter中请求一个json串并参数化,有篇博客写的比较好,大家可以参考...
  • 在发post请求的时候,有时候body部分要传data参数,有时候body部分又要传json参数,那么问题来了:到底什么时候该传json,什么时候该传data? 一、识别json参数 1.在前面1.8章节讲过,post请求的body通常有四种...

空空如也

空空如也

1 2 3 4 5 ... 20
收藏数 3,025
精华内容 1,210
关键字:

json参数化