zoukankan      html  css  js  c++  java
  • postman接口测试之获取响应数据

    一、获取响应行中的状态码

    //获取数据
    var code=responseCode.code;
    //打印code
    tests[code]=true;

    如下图所示:

    二、获取响应行中状态码名字

    //获取数据
    var codename=responseCode.name;
    //打印
    tests[codename]=responseCode.name;

    如下图所示:

    三、获取响应时间

    //获取响应时间
    var time=responseTime;
    tests[time]=true;

    如下图所示:

      

    四、获取响应头的Content_type

    //获取响应头部信息的Content-Type
    var header=postman.getResponseHeader('Content-Type');
    //打印
    tests[header]=true;

    如下图所示:

    五、获取响应cookies中的value值,括号中填写cookies的name值

    //获取cookies中的value值
    var cookies=postman.getResponseCookie('cookies的name值').value;
    //打印
    tests[cookies]=true;

    如下图所示:

     

      六、获取响应正文

    //获取body
    var body=responseBody;
    //打印
    tests[body]=true;

    如下图所示:

    七、正则表达式截取响应body里面的属性值

    //获取body
    var body=responseBody;
    //获取body中的title
    var title=body.match(new RegExp('<title>(.+?)</title>'));
    //打印title
    tests[title]=true;

    如下图所示:

     
  • 相关阅读:
    list for循环中删除元素
    XMLFeedSpider例子
    myeclipse一直卡在loading workbench解决方法
    代码
    在Github上面搭建Hexo博客(一):部署到Github
    RegEX正则表达式截取字符串
    将后台值传单前台js接收
    C# List<T>泛型用法
    基于jQuery——TreeGrid
    在线编程学习网站
  • 原文地址:https://www.cnblogs.com/puhongjun/p/12865239.html
Copyright © 2011-2022 走看看