美文网首页
Python&selenium 自动化测试框架之 生成测试报告后

Python&selenium 自动化测试框架之 生成测试报告后

作者: 乘风破浪的姐姐 | 来源:发表于2022-08-20 11:30 被阅读0次

    pytest和allure生成测试报告后,pycharm中打开index.html时可正常打开,但是不通过pycharm,而是直接到report文件夹下, 双击打开index.html文件,打开的报告无法展示数据,显示loading


    image.png

    原因是allure生成的html测试报告,无法直接双击在浏览器中打开,需要用allure命令,执行后自动打开浏览器。

    allure有两种方式来渲染页面。分别是 allure open 和 allure serve。这里通过allure open在本地渲染后对外展示结果。
    将allure open命令写入到bat文件中,直接双击执行即可。

               os.system(f'allure generate {prpore_json_dir} -o {prpore_allure_dir} --clean')
                logger.info('测试报告生成完成!')
    
                # 测试报告路径
                report_path = os.path.join(os.path.dirname(__file__), 'output')
                # 生成的bat文件路径,该文件至于测试报告平级
                bat_file_path = os.path.join(report_path , '测试结果.bat')
                if os.listdir(prpore_allure_dir):
                    with open(bat_file_path, 'w') as f:
                        f.write("allure open report_allure/ ")
    

    查看测试报告直接双击 测试结果.bat 文件就行了!

    相关文章

      网友评论

          本文标题:Python&selenium 自动化测试框架之 生成测试报告后

          本文链接:https://www.haomeiwen.com/subject/txpugrtx.html