ScreenshotNeo

BlogHow-to

How to Take a Selenium Screenshot of an Indian Web Page with a Bengali Font

Capture an Indian web page with Selenium and render Bengali text correctly by loading the right font, waiting for fonts and content, and using a fixed viewport.

By the ScreenshotNeo team4 October 20267 min read

To take a Selenium screenshot of an Indian web page with Bengali text, make sure the browser can load a Bengali-capable font, wait for both page content and fonts to finish loading, set a repeatable viewport, and then save the browser image as a PNG. If Chrome runs in a container or CI environment, the font must be available there, even if it is installed on your development machine. Bengali shaping, locale, and font availability are separate concerns.

1. Prepare Selenium, Chrome, and the font

Selenium WebDriver controls a browser locally or remotely. For Chrome, keep Chrome and ChromeDriver on the same major version. Current Selenium setups can manage drivers through Selenium’s supported driver management, or you can provide a matching ChromeDriver yourself. See the Selenium WebDriver overview and Chrome-specific Selenium guidance.

The browser also needs a font that covers Bengali. If the page loads its own Bengali web font, allow that request to complete. If it relies on a system font, install or bundle that font in the runtime that launches Chrome. Noto Sans Bengali is one suitable Bengali-script family. Installing a font on the host does not automatically make it available inside a container.

If you control the site CSS, put the Bengali font before generic fallback families, for example:

body {
  font-family: "Noto Sans Bengali", "Noto Sans", sans-serif;
}

A browser falls back to later families when an earlier family does not provide a character. A font name in CSS does not install that font, and a locale setting does not supply it. Bengali uses complex text layout, so inspect real strings in the resulting image to confirm that conjuncts and marks look right. See Noto’s documentation on Noto and script support.

2. Capture the page in Python

Install Selenium in the Python environment that will run the script:

python -m pip install selenium

Then save this as screenshot_bengali.py. Replace the example URL and add a site-specific readiness selector if the page fills in after its initial load.

from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait

URL = "https://example.in/"
OUTPUT = "indian-page.png"

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

driver = webdriver.Chrome(options=options)
try:
    driver.set_window_size(1440, 1200)
    driver.get(URL)

    wait = WebDriverWait(driver, 20)
    wait.until(lambda d: d.execute_script("return document.readyState") == "complete")

    # Wait for the browser's current document fonts to settle.
    driver.execute_async_script("""
        const done = arguments[0];
        document.fonts.ready.then(() => done(true), () => done(false));
    """)

    # Optional: wait for a page-specific signal, for example:
    # wait.until(lambda d: d.find_element("css selector", ".article-content").is_displayed())

    driver.save_screenshot(OUTPUT)
finally:
    driver.quit()

Selenium documents save_screenshot(filename) as saving the current window to PNG. Its navigation wait covers the page load event, but client-rendered content may arrive later. The font readiness wait above is practical browser-side guidance; verify it in the browser version you deploy. Pair it with a selector or application signal when the target page has delayed content. See Selenium’s window and screen documentation.

3. Use cURL, Python, or Node.js with ScreenshotNeo

If the goal is an image of the rendered page rather than control over a local browser session, ScreenshotNeo provides a screenshot API. One GET request takes a URL and returns an image or PDF. Its documented parameters include viewport, device presets, full-page capture, custom CSS and JavaScript, wait conditions, headers, cookies, user agent, and output format. See the ScreenshotNeo API documentation for request options and exact parameter names.

cURL

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

Python

import requests

r = requests.get(
    "https://api.screenshotneo.com/v1/shot",
    params={"access_key": "YOUR_API_KEY", "url": "https://example.in/"},
    timeout=90,
)
r.raise_for_status()
open("shot.webp", "wb").write(r.content)

Node.js

const q = new URLSearchParams({
  access_key: 'YOUR_API_KEY',
  url: 'https://example.in/',
});
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(fs => fs.writeFile('shot.webp', bytes));

Or skip the browser setup

ScreenshotNeo removes cookie banners, newsletter popups, and chat widgets before capture. Bot checks, blank pages, failed loads, timeouts, and cache hits are not billed; response headers report the page verdict and billing status. Its MCP server lets Claude, Cursor, and other MCP clients take screenshots. The free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000 screenshots.

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

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

4. Choose waits, viewport, locale, and capture scope

Wait for the right readiness signal

  • Document loaded: document.readyState == "complete" confirms the document load state, not that a single-page app has finished rendering.
  • Fonts ready: wait for document.fonts.ready when the page uses web fonts or may trigger font loading after navigation. If a font request fails, this promise alone does not prove the desired family rendered; check the actual page and network behavior.
  • Page-specific content: wait for an element or application-ready condition that identifies the content you need, such as a headline or Bengali text container.
  • Delay: use a fixed delay only when the application has no observable readiness condition. It can make captures slower while still being too short under load.

Make capture dimensions repeatable

Set the window size explicitly so line wrapping and responsive breakpoints are predictable. For high-density or mobile output, select the relevant browser/device configuration and device scale deliberately; record it alongside the screenshot. A screenshot of the current window is not automatically a full-page screenshot. If the deliverable is one element, Selenium supports element-level screenshot APIs; check the API and headless requirements for the Selenium and browser versions you use in the Selenium documentation.

Set locale only when the page needs it

Locale can affect date formatting, language selection, or site behavior. It does not install a Bengali font and does not guarantee Bengali glyph shaping. Selenium’s Python BiDi API offers locale override for selected browsing contexts using a BCP 47 locale string; use it when the page behavior depends on locale, and keep font loading as a separate setup step. See the Selenium BiDi documentation.

5. Troubleshoot missing or incorrect Bengali text

Symptom Likely cause What to check or change
Boxes or missing glyphs The font is unavailable to Chrome, or a web-font request failed. Check font availability inside the browser runtime or container, and confirm the page’s font request succeeds. Add the font to the runtime or correct the web-font loading path.
Unexpected font appearance The named family is absent or the CSS fallback order differs from the expected one. Inspect computed CSS and ensure a Bengali-capable family comes before generic fallbacks. Confirm that the family is actually installed or loaded.
Letters appear but conjuncts or marks look wrong Font presence alone does not guarantee correct complex-script shaping. Inspect representative Bengali words in the saved PNG and check browser shaping support and the selected font. Compare the screenshot with the page rendered in a normal browser.
Blank or incomplete screenshot The page load event occurred before app content appeared, or capture ran before fonts settled. Wait for the specific content element and fonts; use an application-ready condition if available.
Chrome session fails to start Chrome and ChromeDriver versions are incompatible, or options do not fit the environment. Align their major versions, verify the Chrome binary is available, and check the headless arguments for your environment.
Element screenshot fails The API, driver, or headless browser version does not support the expected element capture behavior. Check the Selenium element screenshot documentation for the selected browser and version, then verify whether the requirement is for an element or the viewport.
Different line wrapping between runs Viewport, device scale, loaded font, or page state changed. Set a fixed window size and consistent device scale; wait for the intended font and content before saving.

6. Reliability, performance, and cost

  • Reliability: use a fixed browser and driver setup, explicit waits, and a fixed viewport. Always call driver.quit() in a finally block so browser processes are closed on errors.
  • Runtime: fonts and page-specific waits add time, but they avoid capturing a fallback font or incomplete page. Prefer a meaningful readiness condition over an arbitrary long sleep.
  • Reproducibility: record the URL, browser and driver versions, viewport, device scale, font source, and wait condition with the output. Site changes and network policy can still alter rendering.
  • Cost: local Selenium uses your own compute and browser runtime; execution time and infrastructure determine its operational cost. ScreenshotNeo offers 1,000 free shots monthly with no card, then plans from $5 for 3,000; higher listed plans are Growth $15 for 15,000, Pro $39 for 60,000, Scale $99 for 250,000, and Business $249 for 1,000,000. Yearly billing gives two months free, and every feature is on every plan.

7. FAQ

Does setting a Bengali locale fix boxes in the screenshot?

No. Locale can change page behavior, but the browser still needs a Bengali-capable font and shaping support.

Can I use a font installed on my laptop in a CI container?

Only if that font is also made available in the container that runs Chrome, or the page loads it as a web font.

Is a screenshot taken after the page load event always complete?

No. Apps can render content and load fonts after that event. Wait for the relevant content and font state.

How do I know Bengali rendered correctly?

Inspect the saved image using representative Bengali text from the target page, especially words with conjuncts and marks.