ScreenshotNeo

BlogHow-to

How to Take Screenshots of Indian Bank Web Pages with Selenium for Documentation

Capture an authorized bank page with Selenium, save the right scope, and preserve useful context while limiting sensitive information.

By the ScreenshotNeo team4 October 20269 min read

Use Selenium Python to open the specific page you are authorized to document, wait until the content of interest is visible, and save the current browser window with driver.save_screenshot(). That captures the viewport, not necessarily the entire page. Choose the narrowest capture that records what you need, inspect the resulting file, and limit or redact personal information before sharing it.

1. Capture a page with Selenium Python

This runnable example creates an output directory, sets a repeatable viewport, waits for the main content, saves a PNG, checks Selenium’s return value, and always closes the browser. Replace the example URL and readiness selector with a public or otherwise authorized page and a stable selector from that page.

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

output = Path("artifacts")
output.mkdir(parents=True, exist_ok=True)

options = webdriver.ChromeOptions()
# For a visible browser, omit this line. Headless mode is useful in automation.
options.add_argument("--headless=new")

driver = webdriver.Chrome(options=options)
try:
    driver.set_window_size(1440, 1000)
    driver.get("https://www.example-bank.in/public-page")

    WebDriverWait(driver, 20).until(
        EC.visibility_of_element_located((By.CSS_SELECTOR, "main"))
    )

    saved = driver.save_screenshot(str(output / "bank-page.png"))
    if not saved:
        raise IOError("Selenium could not save the screenshot")
finally:
    driver.quit()

Selenium Manager can manage browser drivers for many standard setups when creating the driver this way. If your environment manages browser and driver binaries itself, configure those according to that environment. The official Selenium WebDriver documentation covers driver setup and browser interaction; the Python WebDriver API documents the screenshot method and its return value.

Make the readiness check match the evidence

The example waits for main to become visible. A generic container may appear before the specific text or data you need. Prefer a stable heading, status, or content element that demonstrates the intended page state:

WebDriverWait(driver, 20).until(
    EC.visibility_of_element_located((By.CSS_SELECTOR, "h1.page-title"))
)

For a page that updates asynchronously, wait for the relevant result rather than sleeping for an arbitrary duration. If the page needs a short settling period after the result appears, a small explicit wait can help, but it is less reliable than waiting on a meaningful condition.

2. Choose the right capture scope

Need Method What to expect
What is visible in the browser window driver.save_screenshot("page.png") Current viewport only; lower content may be outside the image.
A specific component or region Find the element and call its screenshot() method Focused image of that element; useful when the surrounding page is irrelevant.
The full document in Firefox Firefox Python methods such as get_full_page_screenshot_as_file() or save_full_page_screenshot() Firefox-specific API; verify support in the installed Selenium and browser versions.
Print-oriented or paginated record driver.print_page() Returns PDF data; print layout can differ from the interactive page’s pixels.

Capture one element

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

panel = WebDriverWait(driver, 20).until(
    EC.visibility_of_element_located((By.CSS_SELECTOR, "main .notice"))
)
if not panel.screenshot("artifacts/notice.png"):
    raise IOError("Could not save element screenshot")

Use a selector that identifies the content you intend to document. Element screenshots avoid unrelated page regions, but the crop may omit context that explains where the element came from. Keep the URL and a description with the image when that context matters.

Capture a full page or PDF

Full-document screenshots are not implemented uniformly across browser drivers. Selenium’s Firefox Python API documents full-page methods; treat them as Firefox-specific and check the API for your installed version before building a workflow around them. For portable documentation, capture the viewport or an element, or use browser-specific functionality you have verified.

To print the current page to PDF with Selenium Python, use print_page(). It returns a Base64-encoded PDF string:

import base64
from pathlib import Path

pdf_data = driver.print_page()
Path("artifacts/bank-page.pdf").write_bytes(base64.b64decode(pdf_data))

A PDF is useful when the record should be printable or paginated. It is not a pixel-for-pixel substitute for a browser screenshot: print styles, page breaks, and hidden or rearranged content can change what appears. See the Selenium Python WebDriver API for the available print and screenshot methods.

3. Preserve context and make captures reproducible

  1. Set the viewport. Use the same window dimensions for captures you plan to compare. Record the dimensions.
  2. Wait for the relevant state. Wait for the content being documented, not merely for navigation to start or a generic page container to exist.
  3. Use a descriptive file path. For example, bank-name/page-name/2026-10-03T222152Z.png. Do not put account numbers or other personal details in filenames.
  4. Record capture metadata separately. Note the URL, UTC capture time, browser and Selenium versions, viewport dimensions, and a short description of the state. Keep sensitive metadata protected too.
  5. Inspect the image. A successful return value means the file was written; it does not prove the intended content was visible or that the image is legible.
  6. Keep originals access-controlled. If an evidentiary record requires an original, preserve it under restricted access and make a separate redacted copy for wider circulation. Record that the copy was redacted.

These steps make an image easier to interpret later. They are practical documentation recommendations, not a bank-specific evidence standard.

4. Handle bank information carefully

Bank pages may expose names, account identifiers, balances, transactions, or other personal information. Prefer public pages or synthetic/demo data. For authenticated pages, obtain the necessary authorization, capture only what the documentation requires, avoid collecting credentials or one-time passwords, and restrict access and retention. Redact a separate copy before sharing it, and check the bank’s current terms and your organization’s policy.

RBI guidance addresses confidentiality of account-opening information and protection of customer information by regulated entities. India’s Digital Personal Data Protection Act, 2023, defines digital personal data and has commencement provisions that depend on government notifications. These sources provide context for careful handling; they do not establish a Selenium-specific permission to capture a page or decide whether a particular capture may be retained or published. Check the current source text and applicable requirements for your situation:

5. Troubleshooting

Symptom Likely cause Fix
WebDriverException while creating the browser Browser installation, driver setup, or environment configuration is missing or incompatible. Confirm the browser is installed and usable in the execution environment. Check Selenium’s driver setup guidance and use a compatible, managed driver configuration.
Wait times out for main or the chosen selector The selector does not match this page, the content is in a frame, or the page did not reach the expected state. Inspect the authorized page, select a stable visible element, and switch to the correct frame if the content is framed. Do not replace the condition with a long blind sleep.
Screenshot is blank or shows a loading state The capture ran before the useful content rendered, or the requested page did not load as expected. Wait for a page-specific element or status. Inspect the browser state and URL before saving. Do not assume a successful file write means a successful page load.
Content is missing below the fold save_screenshot() captured the current viewport. Scroll or capture the relevant element if that is sufficient, use a verified browser-specific full-page method, or create a PDF if print output suits the record.
Image differs between runs Viewport, page state, timing, browser version, or dynamic content changed. Fix and record viewport and versions, wait on the same condition, and note dynamic content or capture time. A live page can change between captures.
File is absent or method returns False Output directory or file path is invalid, or the process cannot write there. Create the directory first, use a writable absolute or project-relative path, and check the return value as in the example.
Element screenshot fails or crops the wrong region The element is not visible, selector matched the wrong node, or layout changed. Wait for the intended element to be visible and verify the selector and crop in the saved image.
PDF looks different from the browser Print styles and pagination differ from screen rendering. Use a PNG for the visible browser appearance; use PDF when printable page output is the requirement.

6. Performance, reliability, and cost

A viewport screenshot is generally the simplest capture because it saves only the visible browser window. Element capture can reduce irrelevant material and the amount of sensitive data in the output. Full-page capture and PDF printing may involve more page content and should be selected only when the documentation needs them. Selenium itself is open-source software; browser execution still uses machine time and resources, and any hosting or managed-browser charges depend on the environment you choose.

Reliability comes mainly from controlling the page state: wait for a meaningful condition, set the viewport, keep browser and driver versions compatible, check that the file was written, and inspect it. Dynamic content can still vary. For bank pages, a reproducible workflow should also minimize data collection and protect both the image and its accompanying metadata.

7. Or skip the browser setup

If the page is public and you need a quick image without managing a local browser, ScreenshotNeo is a website screenshot API and MCP server. Its capture flow accepts cookie or consent banners and removes more than 60 known consent platforms, newsletter popups, and chat widgets before taking the shot; each step can be turned off. Bot checks, blank pages, failed loads, timeouts, and cache hits are not billed, and response headers report the page verdict and billing status. AI agents can use its MCP tools to take screenshots, get page information, or capture PDFs.

One GET request returns an image. Keep bank data and authorization requirements in mind; use this for pages you are permitted to capture. See the ScreenshotNeo API documentation for request options and setup.

curl -G "https://api.screenshotneo.com/v1/shot" \
  -d access_key=YOUR_API_KEY \
  --data-urlencode url=https://www.example-bank.in/public-page \
  -o bank-page.webp
import requests

r = requests.get(
    "https://api.screenshotneo.com/v1/shot",
    params={
        "access_key": "YOUR_API_KEY",
        "url": "https://www.example-bank.in/public-page",
    },
    timeout=90,
)
r.raise_for_status()
open("bank-page.webp", "wb").write(r.content)
const q = new URLSearchParams({
  access_key: 'YOUR_API_KEY',
  url: 'https://www.example-bank.in/public-page',
});
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);
if (!res.ok) throw new Error(`Screenshot request failed: ${res.status}`);
const bytes = new Uint8Array(await res.arrayBuffer());
await import('node:fs/promises').then(({ writeFile }) => writeFile('bank-page.webp', bytes));

ScreenshotNeo includes 1,000 screenshots a month on the free plan with no card; paid plans start at $5 for 3,000 screenshots. Every feature is available on every plan. The one-call workflow can avoid local browser and driver setup, while Selenium remains useful when you need to interact with a specific browser session or authenticated state.

Create a free ScreenshotNeo account for 1,000 screenshots a month with no card.

8. Frequently asked questions

Does Selenium capture a full page by default?

No. The standard WebDriver screenshot saves the current window viewport. Full-page methods are browser-specific; Selenium’s Python API documents them for Firefox.

Can I document a signed-in bank page?

Only when you have the necessary authorization and can protect the resulting image and metadata. Avoid capturing credentials or one-time passwords, minimize the information in frame, and redact copies before sharing.

What should accompany a screenshot?

At minimum, record the page URL, UTC capture time, browser and Selenium versions, viewport dimensions, and a short note describing the visible state. Store this context with appropriate access controls.

When should I use PDF instead of PNG?

Use PDF when print layout or pagination is useful. Use PNG when you need to preserve what appeared in the browser viewport.