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

Use Selenium WebDriver to open the page in a real browser, set a known viewport, wait for the content you need, and save the rendered browser window as a PNG. Then inspect that PNG in the same machine or container where the script will run: Selenium captures rendered pixels, but it cannot guarantee that the environment has fonts capable of displaying Devanagari.

What you need before capturing a page

Selenium WebDriver controls a browser. A working setup needs a Selenium language binding, a browser, and a corresponding browser driver. This example uses Python with Chrome; consult the Selenium getting started documentation for setup details for your operating system and binding.

Use a public page or an account you are authorized to access. Government pages can include personal or case information, so do not publish screenshots containing data you should keep private.

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

Capture a Hindi government page as a PNG with Python

Install the Selenium Python package in your active Python environment, and make sure Chrome is available. The example uses Chrome’s current headless mode, fixes the browser viewport, opens a sample government-domain URL, waits for the page load, and writes a PNG to an absolute path. Replace the sample URL with the page you are authorized to capture.

from pathlib import Path
from selenium import webdriver

out = Path("screenshots/hindi-government-page.png")
out.parent.mkdir(parents=True, exist_ok=True)

options = webdriver.ChromeOptions()
options.add_argument("--headless=new")

driver = webdriver.Chrome(options=options)
try:
    driver.set_window_size(1365, 1000)
    driver.get("https://example.gov.in/")

    # Replace this with a page-specific readiness condition when possible.
    driver.implicitly_wait(2)

    driver.save_screenshot(str(out.resolve()))
finally:
    driver.quit()

Selenium’s Python API documents save_screenshot(filename) for saving the current window as PNG and advises using a full path and the .png extension. The two-second implicit wait above is illustrative, not a reliable general-purpose page-rendering delay: implicit waits apply to element searches, not to every asynchronous update or font load. See the Selenium Chrome WebDriver API and Chrome Headless documentation.

Wait for the page content you actually need

driver.get() waits for the page load event, but a site may continue rendering application content afterward. For a dynamic page, replace the illustrative wait with an explicit condition tied to meaningful content—for example, the presence of a results table or notice you intend to capture.

For example, if the target page has a stable element ID, wait for it to appear before taking the screenshot:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import WebDriverWait

# After driver.get(target_url):
WebDriverWait(driver, 20).until(
    EC.visibility_of_element_located((By.ID, "main-content"))
)
driver.save_screenshot(str(out.resolve()))

Replace main-content with a selector that exists on the actual page. A fixed delay can be useful for a quick diagnostic, but it may be too short on a slow load and unnecessarily long on a fast one. Chrome’s Headless documentation describes capture after page load by default and options for delay or virtual-time budgets; when controlling Selenium directly, a page-specific readiness condition makes the reason for waiting clearer.

Choose the right capture area

Capture method Best for What to keep in mind
Current browser window A page view where surrounding navigation, labels, or context matters The screenshot reflects the current window viewport; set and record the viewport for reproducible comparisons.
Specific element A particular notice, table, or panel that is the evidence you need It omits surrounding page context. Selenium documents element screenshots in its browser-window guidance.

Use driver.save_screenshot(path) for the current window. To capture a specific element after locating it, call element.screenshot(path). Selenium also exposes screenshot bytes and window size or rectangle controls in its API. See the Selenium browser windows documentation for element screenshot details.

Headless or visible Chrome?

Mode Use it when Trade-off
Headless The capture should run unattended, such as in a scheduled job or container. There is no visible browser window to inspect during execution. Chrome describes headless mode as creating browser windows without displaying platform windows.
Visible You need to watch the page while diagnosing a selector, layout, or rendering issue. It requires a graphical browser session, which may not be available in a server or container.

For visible debugging, remove options.add_argument("--headless=new"). The sources do not establish a speed advantage for either mode on Hindi government websites.

Check Devanagari rendering in the captured file

Open the resulting PNG in the target runtime or copy it to the same environment where downstream users will view it. Confirm that Hindi letters appear as expected rather than boxes, blank spaces, or missing glyphs. A browser screenshot is a capture of what the browser rendered; the reviewed Selenium and Chrome documentation does not guarantee a Devanagari-capable font in any particular operating system, container, or browser setup.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  • If Hindi glyphs are missing, inspect the fonts available in that runtime and the font selected by the page’s CSS.
  • Check the screenshot itself, not just the page in a different desktop browser. The environments may have different fonts.
  • Install or configure an appropriate font only after identifying the target environment’s missing-font issue; there is no universal Selenium font option or universally specified package in the cited documentation.

Make captures reproducible

  • Set the viewport before navigation or capture, and use the same dimensions when comparing screenshots. Selenium provides window sizing controls; Chrome documents --window-size as a companion for screenshot capture.
  • Record the viewport alongside the image if the screenshot is evidence or part of a visual comparison.
  • Wait for a page-specific condition rather than assuming that the load event means all content, images, or fonts have settled.
  • Choose a whole-window or element screenshot based on whether the surrounding context is needed.

Common problems and fixes

The PNG has boxes or missing Hindi letters

The browser’s runtime may not have a font that can render the page’s Devanagari text, or the page may select a font unavailable there. Inspect the PNG in the capture environment, then examine available fonts and the page’s selected font. Selenium itself does not supply fonts.

The screenshot is blank or misses a table or notice

The page may have fired its load event before the relevant application content appeared. Wait explicitly for the target element to become visible, and confirm that your selector matches the page. If the content is below the viewport, scroll it into view before taking an element screenshot, or choose a capture method appropriate to the full content you need.

The screenshot dimensions vary between runs

Set a fixed window size before capture and avoid relying on the machine’s default browser dimensions. Keep the chosen viewport with the output metadata or job record if comparisons matter.

The output path fails or the PNG is hard to locate

Create the destination directory before saving and pass an absolute filename ending in .png. The example creates the folder and resolves the path before calling Selenium.

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

The browser does not start in headless mode

Confirm that Chrome is installed and that Selenium can obtain or use a compatible browser driver in the execution environment. If diagnosing the startup issue, run visibly where a desktop session is available and inspect the browser or driver error output.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Or skip the browser setup

ScreenshotNeo provides a screenshot API and MCP server for developers. A single GET request can return a PNG, JPEG, WebP, or PDF. Its clean-shot steps accept cookie or consent banners and remove more than 60 known consent platforms, newsletter popups, and chat widgets before capture; each step can be turned off. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and response headers report the page verdict and billing status.

For a PNG capture, use the documented endpoint and parameters below; replace the URL with the public page you want to capture. See the ScreenshotNeo API documentation for request details.

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

ScreenshotNeo also offers an MCP server with take_screenshot, get_page_info, and capture_pdf tools for Claude, Cursor, and other MCP clients. The free plan includes 1,000 screenshots per month without a card; paid plans start at $5 for 3,000 screenshots. Check Hindi text in the returned image in your target runtime just as you would with a Selenium screenshot.

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

Sign up for 1,000 free screenshots a month, with no card required.

Government accessibility guidance

The Government of India’s GIGW landing page identifies GIGW Manual 3.0 and accessibility resources. That landing page does not establish Selenium screenshots as an official accessibility or compliance workflow; treat this method as a browser-capture technique, not a compliance certification.

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.