You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Thank you for the answer!
Maybe async pattern did not work in our case. But we found another way to solve this problem, I desided to post it here if someone else needed to make screenshot on failed tests for async Playwright:
Call make screenshot in the separate async function:
from pathlib import Path
from playwright.async_api import Page
async def save_screenshot(page: Page, path: Path) -> None:
await page.screenshot(path=str(path))
Call this function in the pytest_runtest_makereport in the loop:
What's the problem this feature will solve?
I'm trying to make scteenshots on test failture.
The ways I found in internet is to make it via
pytest_runtest_makereport
hook.Somthing like:
But I got an error:
RuntimeWarning: coroutine 'Page.screenshot' was never awaited
The reason of error is that
async_page
fixture is async:Describe the solution you'd like
I'd like to have an option to call async functions in Pytest hook.
Or if there are any solutions already exiss, please tell me)
The text was updated successfully, but these errors were encountered: