zoukankan      html  css  js  c++  java
  • Python接口测试-利用登录后的session用到登录后的接口中

    有些接口是在登录后才能调用的,例如“立即出借”只有在登录后才能到出借窗口,解决:

    主要是添加了:

    s =requests.session()

    完整代码:

    '''登录 '''
    print('*'*100,'
    ','54-/systLogonUser/adminLogon.do','
    ','*'*100)
    s =requests.session()
    url1='{0}/systLogonUser/adminLogon.do'.format(yuming)
    headers = {'Content-Type':'application/x-www-form-urlencoded; charset=UTF-8',
               'Accept':'application/json, text/javascript, */*; q=0.01',
               'Referer':'{0}/systLogonUser/login.do'.format(yuming)}
    data = {
        'userName':'18200717108',
        'pwd':'123456Aa',
        'verifyCode':121
    }
    r = s.post(url=url1,data=data,headers=headers)
    repones = r.text
    print('2',r.status_code)
    print('1',r.text)
    
    ''' 用户登录状态'''
    print('*'*100,'
    ','/personal/bala','
    ','*'*100)
    url='{0}/personal/bala?_=1556108604971'.format(yuming)
    r=s.get(url=url,headers=headers11)
    print(r.status_code)
    print(r.text)

    查看返回结果:

    54-/systLogonUser/adminLogon.do 
     ****************************************************************************************************
    2 200
    1 {"fundAcc":"9595100075594008","success":true}
    **************************************************************************************************** 
     /personal/bala 
     ****************************************************************************************************
    200
    {"time":"20760616054726","accountBala":"8270000.80","usableBala":"7602900.80","frozenBala":"667100.00","code":"0","msg":"OK"}
    
    Process finished with exit code 0
  • 相关阅读:
    EventBus
    Date 时间 日期 常用方法函数
    线程 Thread Handler
    MySQL-DoubleWrite
    MySQL各版本优化器变化
    MySQL优化器-条件过滤(condition_fanout_filter)
    PXC集群搭建
    mysql主从不一致--relay_log_recovery设置成0
    MySQL5.7-sql_mode
    根据ibd文件进行数据恢复或导入
  • 原文地址:https://www.cnblogs.com/jpr-ok/p/10814813.html
Copyright © 2011-2022 走看看