ScreenshotNeo

BlogHow-to

Puppeteer Screenshot of a Flipkart Product Page After Choosing a Delivery Location

Use Puppeteer to set a delivery location on a Flipkart product page, wait for the visible update, and capture the result reliably.

By the ScreenshotNeo team4 October 20268 min read

To capture a Flipkart product page after choosing a delivery location, open the product page in Puppeteer, interact with the location controls currently shown on the page, wait for a visible confirmation or updated delivery result, and then call page.screenshot(). The exact selectors and interaction sequence can change, so inspect the live page instead of relying on a guessed selector. Flipkart’s seller shipment API is not evidence of a public shopper API for changing a delivery location.

This guide shows a runnable Puppeteer scaffold. You must fill in the selectors and interaction steps after inspecting the current page. It does not claim that a particular selector or flow has been verified against Flipkart.

1. Install Puppeteer and prepare the script

Use a supported Node.js installation and install Puppeteer in a project directory. Puppeteer’s package manages a compatible browser download by default. See the official screenshot guide and Page.screenshot() API.

mkdir flipkart-capture
cd flipkart-capture
npm init -y
npm install puppeteer

Save the following as capture.js. Set FLIPKART_PRODUCT_URL to the product URL, and replace the marked selectors and steps based on the page you inspect.

const puppeteer = require('puppeteer');

async function main() {
  const productUrl = process.env.FLIPKART_PRODUCT_URL;
  const pincode = process.env.DELIVERY_PINCODE;
  if (!productUrl || !pincode) {
    throw new Error('Set FLIPKART_PRODUCT_URL and DELIVERY_PINCODE');
  }

  const browser = await puppeteer.launch({ headless: true });
  try {
    const page = await browser.newPage({
      viewport: { width: 1440, height: 1000 },
      deviceScaleFactor: 1
    });
    page.setDefaultTimeout(15000);

    await page.goto(productUrl, { waitUntil: 'domcontentloaded', timeout: 45000 });

    // Inspect the current page and replace these placeholders with live selectors.
    // Open the delivery-location control if needed, then enter and submit the pincode.
    const locationControl = 'REPLACE_WITH_CURRENT_LOCATION_CONTROL_SELECTOR';
    const pincodeInput = 'REPLACE_WITH_CURRENT_PINCODE_INPUT_SELECTOR';
    const submitButton = 'REPLACE_WITH_CURRENT_SUBMIT_BUTTON_SELECTOR';
    const confirmation = 'REPLACE_WITH_VISIBLE_UPDATED_DELIVERY_RESULT_SELECTOR';

    await page.locator(locationControl).click();
    await page.locator(pincodeInput).fill(pincode);
    await page.locator(submitButton).click();

    // Wait for an observable result, not merely for an arbitrary delay.
    await page.waitForSelector(confirmation, { visible: true, timeout: 20000 });

    // Optional sanity check: ensure the expected result has rendered.
    const resultText = await page.locator(confirmation).innerText();
    if (!resultText.trim()) throw new Error('Delivery result is visible but empty');

    await page.screenshot({ path: 'flipkart-product.png', fullPage: true });
    console.log(JSON.stringify({
      file: 'flipkart-product.png',
      productUrl,
      pincode,
      capturedAt: new Date().toISOString(),
      deliveryResult: resultText.trim()
    }, null, 2));
  } finally {
    await browser.close();
  }
}

main().catch(error => {
  console.error(error);
  process.exitCode = 1;
});

Run it with environment variables. Use a product URL you are authorized to access and a destination appropriate for your task.

FLIPKART_PRODUCT_URL='https://www.flipkart.com/example-product' DELIVERY_PINCODE='560001' node capture.js

2. Find the live location controls

The research for this guide does not establish a stable location button, modal, input name, or confirmation selector on Flipkart. Inspect the current page in a browser, identify the location UI a shopper can use, and translate that observed flow into selectors. Prefer accessible locators such as labels, roles, and visible text where the current page exposes them; avoid brittle positional selectors and generated class names.

  1. Open the product URL and wait for the relevant product content to appear.
  2. Inspect whether the delivery location is already set, and whether the page offers a control to change it.
  3. Record the actual sequence: open control, enter pincode or choose destination, submit, and dismiss any resulting dialog if appropriate.
  4. Choose a confirmation condition that proves the requested destination or its updated delivery result is displayed.
  5. Replace all four placeholder selectors and the interaction sequence in the script; some pages may require a different number of actions.

Do not treat a visible input alone as proof that the location took effect. Wait for the resulting delivery message, date, or other visible outcome. Flipkart describes serviceability as depending on source and destination locations, and delivery information can vary over time. For evidence or audit use, retain the destination and capture timestamp alongside the image. This is a practical recommendation based on the temporal nature of the result, not a guarantee that every page exposes identical delivery data. See Flipkart’s serviceability engineering explanation.

3. Wait for the update, then capture

waitForSelector() can wait until a selector appears and optionally require it to be visible. It rejects on timeout if the condition does not occur. See the Puppeteer API reference. Use a state the page visibly changes after submission; waiting for a selector that was present before the interaction can produce a misleading capture.

The example uses domcontentloaded for navigation and a separate confirmation wait for the location update. This separates initial document readiness from the asynchronous UI action. If the product details themselves render later, add a wait for the observed product title or content before interacting. Avoid relying on a fixed sleep as the only signal: network and rendering times vary.

Screenshot options

Option Use
path Save the image to a file, as in the example.
fullPage: true Capture the full scrollable page rather than just the viewport.
type Choose a supported image format such as PNG or JPEG; use the documented API for available options and format-specific settings.
clip Capture a selected rectangle when you need a particular region.

Consult the complete screenshot options for details and constraints. Full-page captures can be substantially taller and larger than viewport captures. If the delivery result is the only evidence needed, a viewport capture may be clearer and cheaper to store.

4. Or skip the browser setup

ScreenshotNeo takes a screenshot from one GET request. The request does not perform the Flipkart location interaction shown above; use it when the page is already in the state you need or when a direct capture is appropriate. See the ScreenshotNeo API documentation.

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

ScreenshotNeo accepts cookie and consent banners like a visitor and removes more than 60 known consent platforms, newsletter popups, and chat widgets before capture; each step can be turned off. Bot checks, blank pages, timeouts, failed loads, and cache hits cost nothing, with page verdict and billing information in response headers. Its MCP server lets AI agents use take_screenshot, get_page_info, and capture_pdf. The Free plan includes 1,000 screenshots per month 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.

5. cURL, Python, and Node.js request examples

These examples call ScreenshotNeo’s screenshot endpoint. Replace the URL with a public page you want to capture and provide your API key. They capture the page’s current publicly rendered state; they do not interact with Flipkart’s location controls.

cURL

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

Python

import requests

r = requests.get(
    "https://api.screenshotneo.com/v1/shot",
    params={"access_key": "YOUR_API_KEY", "url": "https://www.flipkart.com/example-product"},
    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://www.flipkart.com/example-product'
});
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);
if (!res.ok) throw new Error(`Screenshot request failed: ${res.status}`);
await require('node:fs/promises').writeFile('shot.webp', Buffer.from(await res.arrayBuffer()));

See ScreenshotNeo’s docs for its available capture parameters. Its options include full-page capture, element selection, device and viewport settings, custom waiting, cookies and headers, caching, and more. Use a supported location or state-setting mechanism only when you have established that it applies to your target page.

6. Reliability, performance, and cost

Reliability

  • Wait for a visible post-submission result, and fail the capture if the expected condition times out.
  • Keep selectors in one place and review them when the page UI changes.
  • Save the product URL, destination, and timestamp with the image when delivery information is important.
  • Close the browser in a finally block so errors do not leave browser processes running.
  • For repeatable runs, log navigation errors, wait timeouts, and the text of the observed delivery result. Do not assume a screenshot alone proves which location was selected.

Performance

Use domcontentloaded for the initial navigation when the page can finish rendering asynchronously, then wait for the specific content and confirmation needed. A full-page image costs more time and storage than a viewport image, especially on long product pages. Keep the viewport and device scale factor consistent if you compare captures across runs. Avoid concurrent browser work beyond the resources available to your host.

Cost and operational notes

Local Puppeteer has no per-screenshot API charge, but you provide the machine, browser installation, execution time, storage, and maintenance. Hosted execution can reduce local setup while adding provider pricing and dependency; no provider or price is evaluated here. ScreenshotNeo’s stated plans are Free: 1,000 monthly shots; Starter: $5 for 3,000; Growth: $15 for 15,000; Pro: $39 for 60,000; Scale: $99 for 250,000; Business: $249 for 1,000,000. Yearly billing gives two months free, and every feature is on every plan. Only clean shots are billed; the service reports page verdict and billing status in response headers.

7. Troubleshooting

Symptom Likely cause What to do
Location selector times out The page UI differs, the control is not open, or the selector is stale. Inspect the current DOM and visible controls; update the selector and open the location control before targeting the input.
Screenshot shows the old destination The script captured before the page applied the new location, or the wait condition matched an unchanged element. Wait for a changed delivery result or destination indicator, not just the input or modal.
Input fill or click fails The element is hidden, covered, disabled, or not the active control. Inspect the current interaction flow, ensure the control is visible and enabled, and use the appropriate user-facing element.
Navigation times out The page did not reach the selected navigation milestone in time. Check the URL and network access, adjust the timeout for your environment, and wait afterward for the product content you actually need.
Blank or incomplete capture The screenshot ran before relevant content rendered, or lazy content has not loaded. Wait for the observed product and delivery result; use a full-page capture only after needed content is present.
Delivery result differs between runs Serviceability and delivery estimates depend on destination and time. Record the destination and capture time, and treat the rendered result as time-specific.
Screenshot file is missing The script failed before reaching the screenshot call or wrote to a different working directory. Read the error and process working directory; confirm the confirmation wait succeeded and use an explicit output path if needed.

8. FAQ

Can I set the shopper’s location with Flipkart’s seller API?

The cited shipment API documents recipient delivery-address details for seller shipment workflows. It does not establish a public consumer API for changing the location shown to a shopper. See the seller shipment details reference.

Should I use a fixed delay after submitting the pincode?

A fixed delay can be a fallback for a known UI transition, but a visible confirmation condition is more informative because it waits for the state that matters.

Does a full-page screenshot prove the page was captured for a particular pincode?

No. Keep the destination and capture timestamp as metadata, and ensure the image itself visibly includes the relevant delivery result when that proof matters.

Can I reuse the same selectors indefinitely?

No selector stability is established here. Reinspect the live page when the workflow fails or its visible controls change.