# 截图
canvas.screenshot("canvas2.png")
# 把截图附在测试报告中,open()打开文件,name相当于重命名,attachment_type选择附件类型
with open("canvas2.png", "rb") as file:
allure.attach(file.read(), name="canvas2", attachment_type=allure.attachment_type.PNG)
右键attachment_type,让我们看看支持哪些附加类型

class AttachmentType(Enum):
def __init__(self, mime_type, extension):
self.mime_type = mime_type
self.extension = extension
TEXT = ("text/plain", "txt")
CSV = ("text/csv", "csv")
TSV = ("text/tab-separated-values", "tsv")
URI_LIST = ("text/uri-list", "uri")
HTML = ("text/html", "html")
XML = ("application/xml", "xml")
JSON = ("application/json", "json")
YAML = ("application/yaml", "yaml")
PCAP = ("application/vnd.tcpdump.pcap", "pcap")
PNG = ("image/png", "png")
JPG = ("image/jpg", "jpg")
SVG = ("image/svg-xml", "svg")
GIF = ("image/gif", "gif")
BMP = ("image/bmp", "bmp")
TIFF = ("image/tiff", "tiff")
MP4 = ("video/mp4", "mp4")
OGG = ("video/ogg", "ogg")
WEBM = ("video/webm", "webm")
PDF = ("application/pdf", "pdf")
276

被折叠的 条评论
为什么被折叠?



