Selenium + Python · Lesson 30 of 43
Module 30: Screenshots
Your task
Implement take_failure_screenshot(driver, save_path):
Write it in the editor, then press Check answer (Ctrl + Enter).
# Full viewport screenshot:
driver.save_screenshot("reports/failure_screenshot.png")
# Element-level screenshot (Selenium 4):
card = driver.find_element(By.ID, "pricing-card")
card.screenshot("reports/pricing_card.png")Visual artifacts are critical when automated tests fail on CI machines. In this lesson, you will master driver.save_screenshot() and element-level screenshots in Selenium 4. Let's capture screenshots!
Part of the Selenium + Python course (Selenium with Python). Practice this concept live in the Selenium Online Compiler or explore our free automation practice form.
PNG is the standard format used by WebDriver for screenshots.
Ready? Solve the task in the editor
Use Check answer to mark it complete. Hints are there if you need them.
___