pip install pytest allure-pytest pytest-selenium
pytest --driver Chrome --alluredir allure-results
Last active
April 26, 2021 11:23
-
-
Save skhomuti/20b345f6478606338fe34ae479ebf59f to your computer and use it in GitHub Desktop.
pytest-selenium and allure screenshot integration
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import base64 | |
import allure | |
def pytest_selenium_capture_debug(item, report, extra): | |
for log_type in extra: | |
if log_type["name"] == "Screenshot": | |
content = base64.b64decode(log_type["content"].encode("utf-8")) | |
allure.attach(content, "Screenshot", attachment_type=allure.attachment_type.PNG) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from selenium.webdriver.chrome.webdriver import WebDriver | |
def test_screenshot(selenium: WebDriver): | |
selenium.get("https://google.com") | |
selenium.find_element_by_id(id_="unexpected") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment