httprunner录制脚本回放时报错:ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:833)
报错提示证书验证失败
所以要关闭证书验证(verify=False))可以解决这个问题或者说是在进行GET-发送请求时,指定SSL证书.
发送请求时加上verify(注意是加在request里,不是加在headers里),代码如下:
config: name: testcase description variables: {} teststeps: - name: /xlc-ops-b/login request: headers: Content-Type: application/json;charset=UTF-8 Sec-Fetch-Mode: cors Sec-Fetch-Site: same-origin User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.130 Safari/537.36 verify: False json: companyId: 7a85fa40b20245f0bec3746593bd713f loginName: '15001990694' password: joyhr@2019 remberPassWord: false method: POST url: https://tes.xinlecai.cn/xlc-ops-b/login validate: - eq: - status_code - 200 - eq: - headers.Content-Type - application/json;charset=UTF-8 - eq: - content.code - 0 - eq: - content.msg - 登录成功 - eq: - content.total - 0 - eq: - content.totalpage - 0
运行成功:
E:\pytest\interface\xlc>hrun xlc_login.yml
INFO HttpRunner version: 2.5.2
INFO Start to run testcase: testcase description
/xlc-ops-b/login
INFO POST https://tes.xinlecai.cn/xlc-ops-b/login
INFO status_code: 200, response_time(ms): 874.91 ms, response_length: 1274 bytes
.
----------------------------------------------------------------------
Ran 1 test in 0.878s
OK
INFO Start to render Html report ...
INFO Generated Html report: E:\pytest\interface\xlc\reports\20200409T030318.944962.html
Sentry is attempting to send 0 pending error messages
Waiting up to 2 seconds
Press Ctrl-Break to quit