allureByTest:AttributeError:“module”对象没有属性“attachment_type”

2024-04-29 01:42:00 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在使用pytest和allure pytest来自动化我的web应用程序测试用例。 我的测试用例有以下格式:

import allure
from selenium import webdriver
class Test_Abc():

    options = webdriver.ChromeOptions()
    options.add_argument("--no-sandbox")
    options.add_argument("--foreground")
    options.add_argument('disable-infobars')
    options.add_argument("--disable-extensions")
    driver = webdriver.Remote(command_executor="http://127.0.0.1:4444/wd/hub", desired_capabilities=options.to_capabilities())

    def test_check_reapply_page_001(self):
        allure.attach(self.driver.get_screenshot_as_png(), "Failed", allure.attachment_type.PNG)

运行测试用例时,在诱惑附加命令:

AttributeError: 'module' object has no attribute 'attachment_type'

请告诉我如何克服这个错误?在

伦敦银行同业拆借:

  • 诱惑力pytest==2.5.4

  • allure python commons==2.5.4

  • pytest==3.7.0

  • 硒==3.141.0


Tags: noimportselfaddattachmentpytesttypedriver
1条回答
网友
1楼 · 发布于 2024-04-29 01:42:00

尝试使用type^{} module attachment type constant,它是一个定义了extension属性的{}。在

对于诱惑:

from allure.constants import AttachmentType

allure.attach('screenshot', driver.get_screenshot_as_png(), type=AttachmentType.PNG)

对于诱惑2:

^{pr2}$

编辑:

看看allures own attachment tests。E、 g组:

 allure.attach(xml_body, attachment_type=allure.attachment_type.XML)

相关问题 更多 >