Python+selenium自动化,Allure包不生成index.html文件,解决方法

查看ui自动化生成的html报告。pytest+allure只生成了xml报告--json格式的数据,没有生成html的index报告。

场景:

  1. 电脑配置了allure的环境变量,配置在系统变量下。

  2. pycharm安装了allure-pytest包

  3. 运行脚本,生成xml类型报告。没有html的报告

排查:
1.cmd输入allure --version,查看是安装成功

image.png

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

image.png

都显示安装、配置成功

3.pycharm软件Terminal中输入allure(海量免费测试资料加1140267353,群内还会有同行一起交流哦~)

image.png

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

最终总算是配置好了~

image.png

解决方法:

  1. 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
  1. 软件右键,用管理员权限运行pycharm,完美解决问题。

猜你喜欢

转载自blog.csdn.net/PythonCS001/article/details/107690858