Closed
Description
Hello,
I have a fixture that implements opening browser and other activities, this is a fixture on a scope of a function.
I would like to add the ability to upload a screenshot to report portal on failure, however, it seems like when it fails, the native report portal logger is unable to send logs from this fixture. the failure handling is on the finally stage.
What should be done?
@pytest.mark.block_asyncio
def setup_and_teardown(self, request):
logging.setLoggerClass(RPLogger)
logger.info("Starting PlayWright client")
self.sb_actions.disable_email_notification_if_exists()
# Determine if --headed was passed
headed = request.config.getoption("--headed")
headless = not headed
self.video_dir = os.path.join(Config.data["logging_directory"], "videos")
self.trace_dir = os.path.join(Config.data["logging_directory"], "traces")
self.screenshot_dir = os.path.join(Config.data["logging_directory"], "screenshots")
os.makedirs(self.video_dir, exist_ok=True)
setup_successful = False
with sync_playwright() as p:
browser = p.chromium.launch(headless=headless)
self.page = browser.new_page(record_video_dir=self.video_dir)
self.start_tracing()
try:
self.setup_playwright_test()
setup_successful = True
yield # opening browser session
self.teardown_playwright_test()
finally:
if setup_successful:
self.stop_tracing()
self.cleanup(request)
browser.close()
Metadata
Metadata
Assignees
Labels
No labels