pytest-html

How to include selenium screenshot in pytest bdd for passed tests?

时光怂恿深爱的人放手 提交于 2021-01-01 07:54:27
问题 I am writing tests in pytest bdd with selenium. I am using pytest-html to generate report. For debug purpose or just to have a proper logging, I want selenium screenshots and rest of the logs in html report. But I am unable to have selenium screenshot in passed report. Here are the things I am trying. There is a pytest-html hook wrapper in conftest.py conftest.py @pytest.mark.hookwrapper def pytest_runtest_makereport(item, call): pytest_html = item.config.pluginmanager.getplugin('html')

Setting dynamic folder and report name in pytest

…衆ロ難τιáo~ 提交于 2020-05-09 05:57:08
问题 I have a problem with setting report name and folder with it dynamically in Python's pytest. For example: I've run all pytest's tests @ 2020-03-06 21:50 so I'd like to have my report stored in folder 20200306 with name report_2150.html . I want it to be automated and triggered right after the tests are finished. I'm working in VS Code and I'm aiming to share my work with colleagues with no automation experience so I'm aiming to use it as "click test to start". My project structure: webtools/

How to handle rerun in pytest with pytest_runtest_makereport fixture

梦想与她 提交于 2020-03-25 17:44:43
问题 I am using pytest-testrail in order to publish some python test cases to testrail. I have a couple test cases that are flaky and using --rerun in order to rerun the test cases that fail. After the rerun, some test cases will pass (meaning the case failed once and passed on the rerun), but pytest will publish the test as failed and pass both. //conftest.py file @pytest.hookimpl(trylast=True, hookwrapper=True) def pytest_runtest_makereport(item, call): report = (yield).get_result() if report

How to handle rerun in pytest with pytest_runtest_makereport fixture

六眼飞鱼酱① 提交于 2020-03-25 17:44:17
问题 I am using pytest-testrail in order to publish some python test cases to testrail. I have a couple test cases that are flaky and using --rerun in order to rerun the test cases that fail. After the rerun, some test cases will pass (meaning the case failed once and passed on the rerun), but pytest will publish the test as failed and pass both. //conftest.py file @pytest.hookimpl(trylast=True, hookwrapper=True) def pytest_runtest_makereport(item, call): report = (yield).get_result() if report

Pytest: how to display generated report after test run?

老子叫甜甜 提交于 2019-12-23 03:25:20
问题 I am using pytest in combination with the pytest-html plugin which generates an HTML report after the test has run. I am using an auto-wired session fixture to automatically open the generated HTML report in a browser: @pytest.fixture(scope="session", autouse=True) def session_wrapper(request): print('Session wrapper init...') yield # open report in browser on Mac or Windows, skip headless boxes if platform.system() in ['Darwin', 'Windows']: html_report_path = os.path.join(request.config

Pytest: how to display generated report after test run?

自闭症网瘾萝莉.ら 提交于 2019-12-06 15:26:22
I am using pytest in combination with the pytest-html plugin which generates an HTML report after the test has run. I am using an auto-wired session fixture to automatically open the generated HTML report in a browser: @pytest.fixture(scope="session", autouse=True) def session_wrapper(request): print('Session wrapper init...') yield # open report in browser on Mac or Windows, skip headless boxes if platform.system() in ['Darwin', 'Windows']: html_report_path = os.path.join(request.config.invocation_dir.strpath, request.config.option.htmlpath) open_url_in_browser("file://%s" %html_report_path)