webdriver - How to add a screenshot to allure report with python? -
i have code:
# coding: utf-8 selenium import webdriver import pytest import allure @pytest.yield_fixture(scope='session') def driver(): _driver = webdriver.phantomjs() yield _driver _driver.quit() def test_ya(driver): allure.step('open ya.ru , take screenshot'): driver.get('http://ya.ru/') allure.attach('screenshot', driver.get_screenshot_as_png(), type='png') and 1 try take screenshot , save allure report, after execution have:
> self._attachfile("%s-attachment.%s" % (uuid.uuid4(), attach_type.extension)) f: if isinstance(body, text_type): e attributeerror: 'str' object has no attribute 'extension' how can fix this?
instead of setting type string png, need use allure module attachment type constant, enum extension attribute defined:
from allure.constants import attachmenttype allure.attach('screenshot', driver.get_screenshot_as_png(), type=attachmenttype.png)
Comments
Post a Comment