我正在使用allure framework为我的pytest测试和行为(BDD)测试生成报告。在pytest中,代码是:
import allure
from allure.constants import AttachmentType
#use the below statement to attach the screenshot
allure.attach('screenshot', self.driver.get_screenshot_as_png(), type=AttachmentType.PNG)
但是,我无法找到类似的方法来将屏幕截图附加到我的HTML报告
答案 0 :(得分:1)
您可以使用以下代码附加某些内容:
srvctl start service -d <DBNAME>
srvctl stop service -d <DBNAME>
答案 1 :(得分:0)
您需要安装allure-pytest然后:
from allure_commons._allure import attach
from allure_commons.types import AttachmentType
attach(
self.driver.get_screenshot_as_png(),
name="Screenshot",
attachment_type=AttachmentType.PNG
)
答案 2 :(得分:0)
from behave import *
from allure_commons._allure import attach
from allure_commons.types import AttachmentType
@Then(u'passed step')
def step_impl(*args, **kwargs):
driver.save_screenshot('screenshot.png')
try:
allure.attach('screenshot.png', name='screenshot', attachment_type=allure.attachment_type.PNG)
except Exception as e:
print(e)
可能您不必使用“ try”,请在此处检查状态: https://github.com/allure-framework/allure-python/issues/431