Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more

With Selenium, open the product page, wait for the product content you need, then save either the visible browser window or a specific element as a PNG. A window screenshot is not automatically a full-page capture, and the right wait condition and viewport depend on the page and what you want the image to show.

What you need before capturing a product page

  • Python and Selenium installed, plus a browser and its WebDriver set up for your environment.
  • The authorized product-page URL and a writable location for the PNG.
  • A clear capture target: the visible browser window, or a specific product-page element such as the main product image.
  • A chosen viewport size if the screenshot needs to be comparable with another capture. Desktop and mobile dimensions produce different responsive layouts.

Selenium’s Python Chromium WebDriver API documents screenshot saving for the current window, as well as screenshot bytes and Base64 output. Its API page identifies itself as Selenium 4.50.0: Selenium Python Chromium WebDriver API.

Capture the visible browser window as a PNG

This example opens the URL supplied on the command line, waits until a product title is visible, records the viewport dimensions, saves the current window as a PNG, checks that the file was saved, and closes the browser.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
from pathlib import Path
import sys

from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import WebDriverWait

if len(sys.argv) < 2:
    raise SystemExit("Usage: python capture_product.py PRODUCT_URL [OUTPUT.png]")

url = sys.argv[1]
output = Path(sys.argv[2] if len(sys.argv) > 2 else "product-page.png")
output.parent.mkdir(parents=True, exist_ok=True)

driver = webdriver.Chrome()
try:
    # Set a repeatable desktop viewport; choose dimensions that suit your use case.
    driver.set_window_size(1440, 1000)
    driver.get(url)

    # Replace this generic example with a selector appropriate to the authorized page.
    title = WebDriverWait(driver, 20).until(
        EC.visibility_of_element_located((By.CSS_SELECTOR, "h1"))
    )

    print("Viewport:", driver.get_window_size())
    print("Visible product title:", title.text)

    if not driver.save_screenshot(str(output)):
        raise OSError(f"Selenium could not save screenshot to {output}")
    if not output.is_file() or output.stat().st_size == 0:
        raise OSError(f"Screenshot file is missing or empty: {output}")
    print(f"Saved {output.resolve()}")
finally:
    driver.quit()

Run it with a product URL and optional output path, for example python capture_product.py "https://example.in/product" "captures/product.png". Replace the example URL and, when needed, the h1 selector with one that matches the page you are permitted to access. A visible heading is only a practical wait condition; a product image or another element may be a better signal for your particular capture.

Why wait for the content you need

Navigation completing does not guarantee that every image, price, delivery detail, or other dynamically loaded component is ready. Wait for the specific content that matters to the screenshot, rather than relying on a fixed sleep. There is no single retailer-independent selector or wait strategy established for Indian ecommerce pages.

Choose and record the viewport

The viewport affects responsive layout and which parts of the page appear in the browser window. Set the dimensions before navigation when repeatability matters, and keep them consistent when comparing captures. A desktop screenshot and a mobile-sized screenshot are different capture scenarios, not interchangeable views of the same layout.

Capture one product-page element instead

When you need a focused image, locate the target and use its screenshot method. Selenium’s official examples document screenshots of selected elements as well as browser screenshots: Selenium windows and tabs documentation.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
from pathlib import Path

from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import WebDriverWait

driver = webdriver.Chrome()
try:
    driver.set_window_size(1440, 1000)
    driver.get("https://example.in/product")

    product_image = WebDriverWait(driver, 20).until(
        EC.visibility_of_element_located((By.CSS_SELECTOR, "img"))
    )
    output = Path("product-image.png")
    if not product_image.screenshot(str(output)):
        raise OSError(f"Could not save element screenshot to {output}")
    print(f"Saved {output.resolve()}")
finally:
    driver.quit()

The generic img selector may match the wrong image; use the page’s appropriate selector for the main product image or other target. An element screenshot is useful for a specific visible region, but the documented behavior does not establish that it captures every off-screen or lazily rendered part of a long page.

Choose the screenshot output that fits the job

Capture choice What it is suited to Important limit
Current browser window saved to PNG The visible page composition at the chosen viewport, including the surrounding context in that window. Do not treat it as a guaranteed full-page capture.
Selected element saved to PNG A focused product image or another individual page element. Does not establish capture of every off-screen or lazily rendered portion.
Screenshot bytes or Base64 Passing screenshot data to another part of a Python workflow instead of saving through the file method. Choose the documented API method that matches how the consuming code expects the data.

The Selenium API documents current-window screenshots as PNG files and also exposes screenshot bytes and Base64: Python Chromium WebDriver screenshot methods. The sources cited here do not establish a built-in full-page guarantee for the documented Python methods.

Inspect the saved screenshot

Open the PNG after each capture workflow change. Confirm that the product details you intended to show are visible and check for overlays, missing images, or a challenge page. If you need a particular price, availability, delivery estimate, or seller detail, verify that it is actually present in the chosen viewport and image; a screenshot only records what was rendered in that capture.

Common problems and fixes

  • The product content is absent: The page may still be rendering, the selector may not match this page, or the content may require a different authorized page state. Wait for the relevant element and check the selector in the browser.
  • The PNG is missing or empty: Use a writable output path, create its parent directory, and check the Boolean result from save_screenshot. Selenium documents that the file method returns False for an I/O error.
  • The capture shows a CAPTCHA or bot check: The screenshot reflects the page state Selenium reached. Do not treat a challenge as a product-page image or attempt to bypass access controls; use authorized access and follow the retailer’s terms.
  • Part of the page is cut off: A current-window screenshot captures the browser window, not a guaranteed full page. Increase the viewport if that serves the task, or capture a specific element; do not assume either method includes all off-screen content.
  • Images or page details are missing: Wait for the specific content you need and inspect the rendered result. A single fixed delay is not a reliable cross-site solution.
  • Desktop and mobile captures differ: Responsive pages can rearrange or hide content at different dimensions. Set and record the viewport for each intended scenario.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Use Indian ecommerce page images responsibly

Indian product pages may show product imagery alongside price, availability, delivery information, seller details, and other context. Define the target by naming both the region or element and the viewport so the saved image’s scope is clear.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Amazon India’s seller image guide concerns seller-submitted images shown on Amazon product detail pages. It says a main image must show the whole product and describes requirements for listing images, including restrictions on text or pricing in applicable images: Amazon India Seller Central product image guide. Those seller-image rules do not establish permission to automate browsing or to reuse a screenshot, and they should not be generalized to Flipkart or other retailers. Check the relevant site’s current terms and use authorized pages, accounts, and data.

Or skip the browser setup

ScreenshotNeo takes a screenshot or PDF from one GET request; see the ScreenshotNeo API documentation. For example, this cURL call saves a WebP capture of a product page:

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://example.in/product -o product.webp

ScreenshotNeo accepts cookie and consent banners before capture and removes more than 60 known consent platforms, newsletter popups, and chat widgets; those steps can be turned off. Bot checks, blank pages, timeouts, failed loads, and cache hits cost nothing, and response headers report the page verdict and billing status. Its MCP server offers take_screenshot, get_page_info, and capture_pdf for AI agents and MCP clients. The free plan includes 1,000 screenshots a month without a card; paid plans start at $5 for 3,000 screenshots. See ScreenshotNeo for the service details. Sign up free for 1,000 screenshots a month, with no card required.

Frequently Asked Questions

Does Selenium’s regular screenshot save the whole ecommerce page?

No. The documented current-window method captures the browser window; it is not established as a guaranteed full-page capture.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Can I save a product screenshot without writing a PNG file first?

Yes. Selenium’s Python Chromium WebDriver API also documents screenshot bytes and Base64 output.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.