ScreenshotNeo

BlogHow-to

How to Take Screenshots of Indian Insurance Websites with Selenium for QA

Capture reproducible screenshots of Indian insurance sites with Selenium: wait for the right UI state, save evidence safely, and troubleshoot flaky captures.

By the ScreenshotNeo team4 October 20268 min read

Use Selenium WebDriver in an authorized test environment, wait for a site-specific signal that the page state you need is ready, then save the browser screenshot. For Indian insurance website QA, run against an approved staging or QA host with approved test accounts and data; a screenshot records what rendered at one moment, but it does not prove that a quote, purchase flow, or regulatory control works correctly.

This guide uses Python and Chrome for a runnable starting point. Replace the example host, locator, and readiness condition with details from your authorized test environment. Selenium also supports other language bindings; the wait-and-capture sequence is the same.

1. Confirm the test scope and prepare the run

  1. Confirm written authorization and use the insurer’s approved non-production environment and test account. Do not automate real quote or purchase journeys without authorization.
  2. Choose a stable scenario and test data. Avoid real customer or policyholder information unless the organization has specifically approved its use for this test and artifact.
  3. Fix the viewport and any relevant browser settings. If the test compares appearance, keep browser version, viewport, locale, test build, and scenario consistent across runs.
  4. Choose a readiness signal that means the exact state under review is visible, such as a quote summary or completed form-step heading. A page load event alone may occur before client-side rendering has finished.
  5. Decide where artifacts will be stored and who can access them. Follow the organization’s approved redaction, retention, and access-control rules.

IRDAI materials provide relevant cybersecurity context for insurers and intermediaries, including a 2022 extension of information and cybersecurity guidelines and a 2020 circular discussing testing provisions. The source set does not determine which rules apply to a particular screenshot workflow today. Verify current instruments and organization-specific privacy and security requirements with the appropriate compliance owners before making compliance claims. IRDAI cybersecurity guidelines (2022), IRDAI circular (2020), IRDAI guidelines index.

2. Install Selenium and the browser

Install Selenium in the Python environment used by your test job:

python -m pip install selenium

Provide a compatible Chrome browser in the environment. Selenium’s driver management can resolve a driver in supported configurations; in locked-down CI, install and configure the approved browser and driver explicitly according to your environment’s policy.

3. Capture a screenshot after the right UI state is ready

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

out = Path("screenshots")
out.mkdir(parents=True, exist_ok=True)

options = webdriver.ChromeOptions()
# In CI, add headless mode if appropriate for your browser setup:
# options.add_argument("--headless")

driver = webdriver.Chrome(options=options)
try:
    driver.set_window_size(1440, 1000)
    driver.get("https://your-authorized-qa-host.example/quote")

    wait = WebDriverWait(driver, 15)
    wait.until(EC.visibility_of_element_located((By.CSS_SELECTOR, "main")))
    # Replace this with a signal for the exact state under test, such as:
    # wait.until(EC.visibility_of_element_located((By.CSS_SELECTOR, ".quote-summary")))

    saved = driver.save_screenshot(str(out / "quote-step.png"))
    if not saved:
        raise RuntimeError("WebDriver did not save the screenshot")
finally:
    driver.quit()

The sample uses a placeholder host and generic main locator; it is not a test performed against an insurer website. Use a locator that is stable in your application and specific to the state being captured. Selenium’s Python WebDriver API documents save_screenshot for saving the current window to a file and get_screenshot_as_png() for returning PNG bytes. Selenium Python WebDriver API.

Use a condition-based wait

Prefer an explicit wait for a visible heading, quote summary, or disappearance of a loading indicator. A fixed sleep can be too short on a slow run and unnecessarily long on a fast one. Selenium warns that mixing implicit and explicit waits can produce unpredictable wait durations; keep implicit waiting disabled when relying on explicit waits. Selenium waiting strategies.

# Example: wait for a completed state and for its loading indicator to go away
wait.until(EC.invisibility_of_element_located((By.CSS_SELECTOR, ".loading")))
wait.until(EC.visibility_of_element_located((By.CSS_SELECTOR, "[data-testid='quote-total']")))

Choose a signal that reflects the test objective. A visible page shell may exist while the quote is still loading, while waiting for a network event unrelated to the user-visible state can delay the test without making the screenshot more meaningful.

4. Choose file output or PNG bytes

For ordinary test artifacts, saving directly to a deterministic path is simplest:

driver.save_screenshot("screenshots/quote-step.png")

If the test framework accepts in-memory artifacts, retrieve bytes and attach them through that framework’s artifact API:

png_bytes = driver.get_screenshot_as_png()
# Pass png_bytes to your test runner's artifact attachment mechanism.

Use unique names when parallel tests might write to the same directory. Include a scenario and step name, and add a run or build identifier in your pipeline. PNG is lossless and convenient for visual diffs, but can produce larger artifacts than compressed formats. Confirm the exact output and retention behavior of the artifact system you use.

5. Make captures reproducible and useful as QA evidence

  • Hold inputs steady: use the same test account, form values, locale, viewport, and browser version when comparing runs.
  • Capture the state, not just the URL: record the scenario and step, and wait for a meaningful UI condition.
  • Preserve context: store browser/version, viewport, locale, build, scenario, timestamp, and the failing URL or test step alongside the image where your reporting system supports it.
  • Capture failures before cleanup: take the screenshot in an exception or test-finalization path before closing the browser, and preserve relevant logs.
  • Protect artifacts: restrict access and apply approved redaction and retention rules, especially if page content could include sensitive information.
  • Review the intended matrix: run across the browsers, viewport sizes, languages, and accessibility configurations your team has selected. A single image covers only one rendered state.

Visual differences can come from changing content, fonts, animations, timestamps, personalized data, browser rendering, or viewport size. Stabilize what the test controls, and treat remaining differences as evidence to review rather than automatic proof of a defect.

6. Troubleshoot common capture problems

Symptom Likely cause Fix
Screenshot shows a spinner or incomplete quote Navigation completed before the application reached the target UI state. Wait for a state-specific element or for the loading indicator to disappear. Check that the locator represents the completed step.
Wait times out The locator is wrong, the expected state was not reached, the page has an error, or the timeout is too short for the environment. Check the current URL and page state, verify the selector in the authorized environment, preserve logs and a failure screenshot, and adjust the timeout only after checking actual readiness behavior.
Screenshot call returns false or file is missing The destination directory does not exist, the path is not writable, or the save operation failed. Create the directory before capture, use a writable artifact path, check the return value, and fail the test if saving did not succeed.
Chrome or driver fails to start Browser and driver setup is missing or incompatible, or the CI environment lacks required browser dependencies. Install the approved browser and compatible driver, configure the environment explicitly if automatic management is unavailable, and inspect startup logs.
Images or other late content are missing The screenshot was taken before the content appeared or before lazy loading was triggered. Wait for a visible, relevant image or content signal. If the test requires content below the initial viewport, scroll as the application requires and wait for it to render before capture.
Visual diffs change on every run Dynamic content, animations, personalization, timestamps, or inconsistent viewport/browser settings. Use stable test data, consistent browser and viewport settings, and application-supported ways to control dynamic state. Record run context to make differences diagnosable.
Screenshot contains sensitive data The test used real or unapproved data, or the page includes information that was not considered before artifact creation. Use approved test data, restrict access, and follow the organization’s redaction and retention procedures. Escalate an exposure according to internal process.

7. Performance, reliability, and cost considerations

A screenshot adds browser work and artifact storage to a test. Capture only the states that provide useful evidence, and avoid writing multiple images to the same filename in parallel. Explicit waits tied to the target state improve reliability over arbitrary delays. Large image artifacts can increase CI upload time and storage use; use the artifact system’s approved retention settings and attach in-memory PNG bytes where that fits its workflow.

Rendering and capture time depend on the site, test environment, browser, and readiness condition; this guide makes no benchmark claim. A screenshot is a record of one viewport and one instant. It cannot establish that all browser configurations, business logic, accessibility behavior, or regulatory obligations passed.

8. Or skip the browser setup

For a one-call capture of a public page, ScreenshotNeo accepts a URL and returns an image or PDF. Its API also has controls for viewport, device presets, full-page capture, waiting, custom CSS and JavaScript, cookies, headers, and other capture needs. See the ScreenshotNeo API documentation.

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

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

These examples target a public sample URL and use a placeholder key; substitute a URL you are authorized to capture and keep the key secret. For insurer QA, an API capture is appropriate only when the target is reachable and authorized for that service. It does not replace Selenium when the test needs to interact with a user journey or verify a specific authenticated state.

  • Cookie and consent banners are accepted before capture, and more than 60 known consent platforms, newsletter popups, and chat widgets can be removed; each step can be turned off.
  • Bot checks, blank pages, timeouts, failed loads, and cache hits cost nothing. Responses identify the page verdict and billing status in headers.
  • An MCP server gives AI agents tools for screenshots, page information, and PDF capture.
  • 1,000 screenshots per month are free with no card. Paid plans start at $5 for 3,000 screenshots.

Learn about ScreenshotNeo, then sign up for 1,000 free screenshots a month with no card.

9. Frequently asked questions

Does a screenshot prove that an insurance quote is correct?

No. It records rendered appearance. Assert the quote values and behavior separately in the test.

Should I capture production pages?

Only if your organization has explicitly authorized that activity and approved the account, data, and method. Prefer the approved QA or staging environment.

Can I use Selenium screenshots as compliance evidence?

They can be artifacts from a QA process, but this guide does not determine their legal or regulatory status. Confirm requirements with your compliance and security owners.

Does setting the window size guarantee a full-page image?

No. It sets the browser window dimensions for the capture. The documented methods here are current-window screenshots; confirm the behavior required by your installed Selenium binding and browser if you need a different capture scope.

Sources