allure report 中截屏无法显示

输入一下函数以及文档目录中,运行一下目录,但是截屏无法显示



显示一次之后怎么试都不会显示了,请各位大佬帮忙,谢谢

需要先以二进制的方式去读这个图片,然后放入allure报告内

            with open("error.png", "rb") as f:
                content = f.read()
            allure.attach(content,attachment_type=allure.attachment_type.PNG)

非常感谢,问题已经解决了。
但是我还有一个疑问想请教一下,看了allure的录播课我用了以下的代码,没有读取文件,在allure报告中也可以正确显示,为什么截屏的文件就一定要读取哪?


因为两个API不一样 attach与attach_file。attach_file封装了读取文件的过程,用这个更简单

奥,明白了,多谢多谢