python接口自動(dòng)化-allure2-報(bào)告添加附件-html

# -*- coding: utf-8 -*-
# @Time    : 2023/7/10 20:56
# @Author  : yanfa
# @user   : yanfa 
# @File    : test_attach_for_html.py
# @remark: 添加附件-html
""""""
import allure

"""
一、Allure2 報(bào)告中添加附件(html)應(yīng)用場(chǎng)景
應(yīng)用場(chǎng)景:
    可以定制測(cè)試報(bào)告頁(yè)面效果,可以將html類型的附件顯示在報(bào)告頁(yè)面
解決方案:
    python:使用allure.attach()添加html代碼
    java:直接通過(guò)注解或調(diào)用方法添加
    
二、Allure2 報(bào)告中添加附件(html)- Python
語(yǔ)法:allure.attach(body, name, attachment_type, extension),參數(shù)解釋:
body:要寫(xiě)入附件的內(nèi)容(HTML 代碼塊)。
name:附件名字。
attachment_type:附件類型,是 allure.attachment_type 其中的一種。
extension:附件的擴(kuò)展名。
"""
class TestWithAttach:
    def test_html(self):
        myhtml = """<html>
        <head>
        <title>這是第二種html注釋-新</title>
        </head>
        <body>
        <h1>這是第二種html注釋-新</h1>
        </body>
        </html>"""
        allure.attach(myhtml,"附件是html類型", allure.attachment_type.HTML)

"""三、Allure2 報(bào)告中添加附件(html) - Java
Allure 支持兩種方法: 
- 注解方式添加:
直接傳入html文件。
@Attachment(value = "html名", type = "text/html", fileExtension = "后綴")

- 調(diào)用方法添加。
使用Allure方法傳入html。
Allure.addAttachment("html名", "text/html",圖片路徑, "后綴");

"""
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容