I am using pytest-bdd, Playwright Python, Allure report for my project. Everything works great but the screenshot for failed tests.
Playwright-pytest has screenshot option --screenshot
but it does not work when using non default context.
https://github.com/microsoft/playwright-pytest/issues/141
https://github.com/microsoft/playwright-pytest/issues/111
I wonder whether it is possible to use pytest-bdd hook pytest_bdd_step_error() to capture the screen. I cannot find example to pass the page
variable to pytest_bdd_step_error() to save the screen.
The reason I define context is because my url is https and I have to let the browser to ignore the warning.
Appreciate any suggestion. I am open to not using pytest-bdd if other html report can capture the screenshot and include in the report.
my conftest.py
@pytest.fixture(scope="session")
def context(browser: Browser):
context = browser.new_context(ignore_https_errors=True)
yield context
context.close()