Skip to content

Instantly share code, notes, and snippets.

@skhomuti
Last active April 26, 2021 11:23
Show Gist options
  • Save skhomuti/20b345f6478606338fe34ae479ebf59f to your computer and use it in GitHub Desktop.
Save skhomuti/20b345f6478606338fe34ae479ebf59f to your computer and use it in GitHub Desktop.
pytest-selenium and allure screenshot integration
pip install pytest allure-pytest pytest-selenium
pytest --driver Chrome --alluredir allure-results
import base64
import allure
def pytest_selenium_capture_debug(item, report, extra):
for log_type in extra:
if log_type["name"] == "Screenshot":
content = base64.b64decode(log_type["content"].encode("utf-8"))
allure.attach(content, "Screenshot", attachment_type=allure.attachment_type.PNG)
from selenium.webdriver.chrome.webdriver import WebDriver
def test_screenshot(selenium: WebDriver):
selenium.get("https://google.com")
selenium.find_element_by_id(id_="unexpected")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment