查看ui自动化生成的html报告。pytest+allure只生成了xml报告--json格式的数据,没有生成html的index报告。
场景:
-
电脑配置了allure的环境变量,配置在系统变量下。
-
pycharm安装了allure-pytest包
-
运行脚本,生成xml类型报告。没有html的报告
排查:
1.cmd输入allure --version,查看是安装成功

2.pycharm输入pip freeze,查看包是否配置成功

都显示安装、配置成功
3.pycharm软件Terminal中输入allure

怀疑是pycharm软件哪里配置除了问题,排查浪费了N多时间。
最终总算是配置好了~

解决方法:
-
cmd = "allure generate ./Report/xml/ -o ./Report/html/ --clean"
上面这行代码不会直接执行,脚本里面需要shll命令去执行
shell =Shell.Shell()
shell.invoke(cmd)
import subprocess
class Shell:
@staticmethod
def invoke(cmd):
output, errors = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()
o = output.decode("utf-8")
return o
- 软件右键,用管理员权限运行pycharm,完美解决问题。

网友评论