How to take a screenshot with Selenium?

You can take a screenshot using the selenium web driver via the save_screenshot method.

Here is some sample code for navigating to the ScrapingBee website and taking a screenshot of the page:

from selenium import webdriver

DRIVER_PATH = '/path/to/chromedriver'
driver = webdriver.Chrome(executable_path=DRIVER_PATH)


screenshot_path = "/path/to/screenshot.png"

# Save the screenshot

Related Selenium web scraping questions: