Selenium driver has
save_screenshot() method which saves a screenshot of the browser viewable area to an image file. Let’s try taking a screenshot by example:
- Open the http://igeorgiev.eu web page.
- Save a screenshot from the page to a file.
URL = "https://igeorgiev.eu"
with contextlib.closing(webdriver.Chrome()) as driver:
driver.save_screenshot(str(SCREENSHOTS_DIR / "igeorgiev-home.png"))