报告无数据
页面报错
Uncaught SyntaxError: Unexpected token ‘,’
Uncaught ReferenceError: statusGroup is not defined
at drawParentChart (extent.js:458)
at extent.js:469
找到html文件
第一个报错说明stat.successes取值有问题
第二个报错应该是第一个报错没取到值引起的
运行项目debug
获取到运行到这一步的_summary值,上面报告所取的值都是从里面解析出来的
{
'success': True,
'stat':
{
'testcases':
{
'total': 1, 'success': 1, 'fail': 0
},
'teststeps':
{
'total': 1, 'failures': 0, 'errors': 0, 'skipped': 0, 'expectedFailures': 0, 'unexpectedSuccesses': 0, 'successes': 1
}
},
'time':
{
'start_at': 1570339928.667485,
'duration': 18.493363857269287,
'start_datetime': '2019-10-06 13:32:08'
},
'platform':
{
'httprunner_version': '2.2.6', 'python_version': 'CPython 3.6.3', 'platform': 'Darwin-16.7.0-x86_64-i386-64bit'
},
'details':
[
{
'success': True,
'stat':
{
'total': 1, 'failures': 0, 'errors': 0, 'skipped': 0, 'expectedFailures': 0, 'unexpectedSuccesses': 0, 'successes': 1
},
'time':
{
'start_at': 1570339928.667485, 'duration': 18.493363857269287
},
'records':
[
{
'name': 'login',
'status': 'success',
'attachment': '',
'meta_datas':
{
'name': 'login',
'data':
[
{
'request':
{
'url': 'http://sistest01.schoolis.cn/api/MemberShip/Login',
'method': 'POST',
'headers':
{
'User-Agent': 'python-requests/2.18.4',
'Accept-Encoding': 'gzip, deflate',
'Accept': '*/*',
'Connection': 'keep-alive',
'Content-Length': '143',
'Content-Type': 'application/json'
},
'body': Markup('{"LanguageType": 1, "isWeekPassword": 0, "name": "\\u674e\\u68a6\\u5a77", "password": "B84E3EE6CCFB49F0D9F20EE88F228958", "timestamp": 1570246711}')
},
'response':
{
'ok': True,
'url': 'http://sistest01.schoolis.cn/api/MemberShip/Login',
'status_code': 200,
'reason': 'OK',
'cookies':
{
'SessionId': 'ae4fca2c-1713-4f5a-939a-fc0535712b19'
},
'encoding': 'utf-8',
'headers':
{
'Date': 'Sun, 06 Oct 2019 05:32:29 GMT',
'Content-Type': 'application/json; charset=utf-8',
'Content-Length': '45',
'Connection': 'keep-alive',
'Cache-Control': 'no-cache',
'Pragma': 'no-cache',
'Expires': '-1',
'X-AspNet-Version': '4.0.30319',
'Set-Cookie': 'SessionId=ae4fca2c-1713-4f5a-939a-fc0535712b19;path=/',
'X-Powered-By': 'ASP.NET'
},
'content_type': 'application/json;charset=utf-8',
'json':
{
'data': '/default.aspx',
'state': 0,
'msg': None
}
}
}
],
'stat':
{
'response_time_ms': 18454.19,
'elapsed_ms': 414.345,
'content_size': 45
},
'validators': []
},
'meta_datas_expanded':
[
{
'name': 'login',
'data':
[
{
'request':
{
'url': 'http://sistest01.schoolis.cn/api/MemberShip/Login',
'method': 'POST',
'headers':
{
'User-Agent': 'python-requests/2.18.4',
'Accept-Encoding': 'gzip, deflate',
'Accept': '*/*',
'Connection': 'keep-alive',
'Content-Length': '143',
'Content-Type': 'application/json'
},
'body': Markup('{"LanguageType": 1, "isWeekPassword": 0, "name": "\\u674e\\u68a6\\u5a77", "password": "B84E3EE6CCFB49F0D9F20EE88F228958", "timestamp": 1570246711}')
},
'response':
{
'ok': True,
'url': 'http://sistest01.schoolis.cn/api/MemberShip/Login',
'status_code': 200,
'reason': 'OK',
'cookies':
{
'SessionId': 'ae4fca2c-1713-4f5a-939a-fc0535712b19'
},
'encoding': 'utf-8',
'headers':
{
'Date': 'Sun, 06 Oct 2019 05:32:29 GMT',
'Content-Type': 'application/json;
charset=utf-8',
'Content-Length': '45',
'Connection': 'keep-alive',
'Cache-Control': 'no-cache',
'Pragma': 'no-cache',
'Expires': '-1',
'X-AspNet-Version': '4.0.30319',
'Set-Cookie': 'SessionId=ae4fca2c-1713-4f5a-939a-fc0535712b19; path=/',
'X-Powered-By': 'ASP.NET'
},
'content_type': 'application/json; charset=utf-8',
'json':
{
'data': '/default.aspx',
'state': 0,
'msg': None
}
}
}
],
'stat':
{
'response_time_ms': 18454.19,
'elapsed_ms': 414.345,
'content_size': 45
},
'validators': []
}
],
'response_time': '18454.19'
}
],
'name': 'login',
'in_out':
{
'in': {},
'out': {}
}
}
]
}
可以看到report_templat.html里的取值路径很多都是和取到的_summary不兼容
就是说有可能是前端代码(HttpRunnerManager)和后端代码(HttpRunner)版本不兼容
查看HttpRunnerManager的requirements.txt
Django == 2.0.3
PyYAML == 3.12
requests == 2.18.4
eventlet == 0.22.1
mysqlclient == 1.3.12
django-celery == 3.2.2
flower == 0.9.2
dwebsocket == 0.4.2
paramiko == 2.4.1
HttpRunner == 1.5.8
终端机中使用pip list
Django == 2.0.3
PyYAML == 5.1.2
requests == 2.18.4
eventlet == 0.22.1
mysqlclient == 1.3.12
django-celery == 3.2.2
flower == 0.9.2
dwebsocket == 0.4.2
paramiko == 2.4.1
HttpRunner == 2.2.6
可以看到PyYAML和HttpRunner版本都不符合要求
终端机运行命令,安装符合要求的版本
pip uninstall PyYAML
pip uninstall HttpRunner
pip install PyYAML==3.12
pip install HttpRunner==1.5.8
PS. 终极原因是配置包没有安装正确版本,移步
https://blog.csdn.net/momo906/article/details/102288731