Install & Compatibility
Where this runs
tested against v3.0.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.910 runs
installs and imports cleanly · install 0.0s · import 0.000s · 72.8MB
glibcpy 3.10–3.910 runs
installs and imports cleanly · install 4.3s · import 0.000s · 74MB
73MB installed
● package 73MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
Screenshot
✓ from Screenshot import Screenshot
✗ from Screenshot import Screenshot_Clipping
This quickstart demonstrates how to set up a headless Chrome WebDriver using `webdriver_manager`, navigate to a page, and then use `selenium-screenshot` to capture both a full-page screenshot and a specific element's screenshot. Version 3.0.0's `full_Screenshot` method leverages Chrome DevTools Protocol (CDP) for more accurate full-page captures.
import os
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.chrome.options import Options
from webdriver_manager.chrome import ChromeDriverManager
from Screenshot import Screenshot_Clipping
# Setup Chrome options for headless mode and window size
chrome_options = Options()
chrome_options.add_argument('--headless')
chrome_options.add_argument('--disable-gpu')
chrome_options.add_argument('--window-size=1920,1080') # Recommended for consistent headless screenshots
# Initialize WebDriver
# Using webdriver_manager to automatically handle driver downloads
service = Service(ChromeDriverManager().install())
driver = webdriver.Chrome(service=service, options=chrome_options)
ob = Screenshot_Clipping.Screenshot()
try:
driver.get('https://www.google.com')
print(f"Navigated to {driver.current_url}")
# Take a full-page screenshot using CDP (requires Chrome/Chromium-based browser)
full_page_screenshot_path = ob.full_Screenshot(driver, save_path=os.getcwd(), image_name='google_full_page.png')
print(f"Full-page screenshot saved to: {full_page_screenshot_path}")
# Find an element and take its screenshot
search_box = driver.find_element(By.NAME, 'q')
element_screenshot_path = ob.get_element_screenshot(driver, search_box, save_path=os.getcwd(), image_name='google_search_box.png')
print(f"Element screenshot saved to: {element_screenshot_path}")
except Exception as e:
print(f"An error occurred: {e}")
finally:
driver.quit()
print("WebDriver closed.")
Debug
Known issues
breakingVersion 3.0.0 introduces significant changes to how full-page screenshots are captured, now primarily utilizing the Chrome DevTools Protocol (CDP). This may require adjustments to existing code, particularly if you were relying on older, less robust full-page methods. The API for `full_Screenshot` remains similar but its underlying implementation is different.fixEnsure your WebDriver is Chrome/Chromium-based for optimal performance with `full_Screenshot`. Review documentation for any changes to specific parameters or behaviors.
affects: <3.0.0
gotcha`full_Screenshot` in v3.0.0+ is optimized for Chrome/Chromium-based browsers due to its reliance on the Chrome DevTools Protocol (CDP). While it might fall back to older methods for other browsers, full-page screenshot accuracy and reliability will be best with Chrome.fixFor consistent and accurate full-page screenshots, use `Chrome` or `Chromium` as your WebDriver. If cross-browser full-page screenshots are critical, thoroughly test the behavior on non-Chrome browsers.
affects: >=3.0.0
gotchaWhen running Selenium in headless mode, especially with older versions or if screenshots appear inconsistent, setting a specific window size (`--window-size`) is crucial for predictable screenshot dimensions and content rendering, even though v3.0.0 improves headless handling.fixAlways add `chrome_options.add_argument('--window-size=WIDTH,HEIGHT')` (e.g., `1920,1080`) to your Chrome options when running in headless mode. affects: All versions, more critical in <3.0.0
gotchaFor `get_element_screenshot`, ensuring the target element is visible and correctly located on the page is critical. Issues with elements being off-screen, hidden, or dynamically loaded can lead to `NoSuchElementException` or incomplete screenshots.fixImplement explicit waits (`WebDriverWait`) to ensure the element is present and visible before attempting to screenshot it. Scroll the element into view if necessary using JavaScript `driver.execute_script('arguments[0].scrollIntoView();', element)`. affects: All versions
Upgrade
Version history
3.0.0latest on PyPI · released May 4, 2025
Audit
Dependencies
seleniumrequiredCore dependency for browser automation and WebDriver interaction.
PillowrequiredRequired for image manipulation and saving screenshots.