• robotframework接口测试初探2


    python这个requests模块常被用来测试接口.使用RequestLibrary库测试之前,先来看下这个模块是怎样使用的

    最简单的调用是

    r=requests.get("http://......")

    r.text

    那么查看结果常用的方法是啥呢?下面把整体都列出来。可以print r.xxx调用查看相应的结果

    __attrs__
    __bool__
    __class__
    __delattr__
    __dict__
    __doc__
    __format__
    __getattribute__
    __getstate__
    __hash__
    __init__
    __iter__
    __module__
    __new__
    __nonzero__
    __reduce__
    __reduce_ex__
    __repr__
    __setattr__
    __setstate__
    __sizeof__
    __str__
    __subclasshook__
    __weakref__
    _content
    _content_consumed
    apparent_encoding
    close
    connection
    content
    cookies
    elapsed
    encoding
    headers
    history
    iter_content
    iter_lines
    json
    links
    ok
    raise_for_status
    raw
    reason
    request
    status_code
    text
    url

    当然requests还有一些其他的方法,不如构造post,headers,等等传递参数进行请求。。。

    >>> payload = {'key1': 'value1', 'key2': 'value2'}
    >>> r = requests.post("http://httpbin.org/post", data=payload)
    >>> print r.text
    网上有很多写的很详细的,参看http://blog.csdn.net/iloveyin/article/details/21444613

    记录这些是为了使用robotframework的RequestLibaray库进行自动化测试

  • 相关阅读:
    html添加注释怎么弄?
    编程语言本身是怎么开发出来的?
    一句话说明Facbook React证书的矛盾点
    XAMPP是什么?
    HTTP解析
    version control
    函数式编程语言
    Servlet之Filter
    Build tool
    container和injection
  • 原文地址:https://www.cnblogs.com/xueli/p/5053196.html
Copyright © 2020-2023  润新知