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

Popular posts from this blog

java - Spring Data JPA: Why findOne(id) executing delete query internally? -

python - Mongodb How to add addtional information when aggregating? -

java - Incorrect order of records in M-M relationship in hibernate -