Skip to content

Commit

Permalink
Fix issue with attaching screenshots
Browse files Browse the repository at this point in the history
  • Loading branch information
root authored and root committed Jul 8, 2024
1 parent aba6e10 commit f5bc054
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions init_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import pytest
from playwright.sync_api import sync_playwright
import allure
import logging

playwright_helper_instance = None
api_helper_instance = None
Expand Down Expand Up @@ -59,12 +60,21 @@ def load_config_from_env():
return config

def attach_screenshot(filename):
logging.basicConfig(level=logging.DEBUG)
if config["browser"] == "mobile":
filename = config["browser"].upper() + "_" + config["device"] + "_" + get_browser_version() + "_" + filename + "_"
else:
filename = config["browser"].upper() + "_" + get_browser_version() + "_" + filename + "_"
screenshot = capture_screenshot(filename)
allure.attach.file(screenshot, name=f"{filename}", attachment_type=allure.attachment_type.PNG)

os.makedirs(os.path.dirname(filename), exist_ok=True)
logging.debug(f"Filename: {filename}")

try:
screenshot = capture_screenshot(filename)
logging.debug(f"Screenshot saved at: {screenshot}")
allure.attach.file(screenshot, name=f"{filename}", attachment_type=allure.attachment_type.PNG)
except Exception as e:
logging.error(f"Failed to capture screenshot: {e}")

config = load_config_from_env()

Expand Down

0 comments on commit f5bc054

Please sign in to comment.