python-3.x - Allure 无法读取生成的 json 文件,并且附件未附加
问题描述
有这样一段代码:
import allure
from selenium.common.exceptions import TimeoutException
from SauceBasePage import *
from SauceProductsPage import *
from SauceCartPage import *
@allure.severity(allure.severity_level.NORMAL)
@allure.title('Removing')
def test_problem_user_remove_item(browse):
user = StartPage(browse)
with allure.step('Open start page'):
user.start_page_open(browse)
with allure.step('Input data'):
user.problem_input()
with allure.step('Login'):
user.standard_login()
user = ProductsPage(browse)
with allure.step('Add product to cart'):
user.add_product_to_cart()
with allure.step('Remove'):
try:
user.remove_product()
assert EC.visibility_of_element_located((By.ID, 'add-to-cart-sauce-labs-backpack'))
except TimeoutException:
allure.attach('Remove error', browse.get_screenshot_as_png(), attachment_type=allure.attachment_type.PNG)
raise AssertionError('Removing failed')
allure.dynamic.title('Remove successfull!')
代码按原样执行,但在执行命令之后:
allure generate
我该如何解决?
解决方案
好吧,我发现错误。它在我的代码中。Шt 应该是这样的:
allure.attach(browse.get_screenshot_as_png(), name="Remove fail" attachment_type=allure.attachment_type.PNG)
推荐阅读
- api - Rest api开发:出现错误:找不到媒体类型=应用程序/xml的MessageBodyWriter
- java - 使用 antlr4 检查 java 代码中的用户输入
- android - 是否可以通过 ./gradlew 命令传递构建配置参数?
- c# - 在 ASP.Net Framwork API 中配置和使用 AutoMapper
- grafana - 使用 Grafana 离散面板监控标签 (InfluxDB)
- c++ - 二叉树到循环双向链表
- python-3.x - 仅使用 Opencv python 裁剪前额
- matlab - 在MATLAB中求解非线性方程组时出错
- c++ - 返回具有随机值的对象的模板函数
- sql - SQL Server 条件下的日期和浮点数转换