How to Capture a Webpage Screenshot with an AI Agent Using a French Locale
Set your browser agent’s locale to fr-FR before navigation, then capture the viewport, full page, or a specific element with Playwright.
Set the browser context locale to fr-FR before navigating to the page. Then capture the viewport, the full scrollable page, or a selected element. In Playwright, locale is a browser-context setting; it does not set the test runner’s timezone. A French locale requests French-language browser behavior, but a website may still choose content based on its URL, account, region, or application logic, so inspect the rendered page before treating the screenshot as French-localized.
1. Capture a French-locale page with Playwright
Install Playwright and its Chromium browser in your project:
npm install playwright
npx playwright install chromium
Save this as screenshot-fr.mjs and run it with node screenshot-fr.mjs:
import { chromium } from 'playwright';
const browser = await chromium.launch();
try {
const context = await browser.newContext({ locale: 'fr-FR' });
const page = await context.newPage();
await page.goto('https://example.com', { waitUntil: 'networkidle' });
await page.screenshot({ path: 'page-fr.png', fullPage: true });
await context.close();
} finally {
await browser.close();
}
The essential setting is locale: 'fr-FR' on the context, created before the page navigates. Playwright uses this to emulate the browser locale, including locale-dependent browser behavior such as the Accept-Language header and JavaScript locale settings. It does not translate the site or guarantee that every page element will be in French.
Choose the screenshot scope
| Need | Playwright option | Example |
|---|---|---|
| Visible viewport | Default screenshot behavior | await page.screenshot({ path: 'viewport.png' }) |
| Entire scrollable page | fullPage: true |
await page.screenshot({ path: 'full.png', fullPage: true }) |
| One element | Locator screenshot | await page.locator('header').screenshot({ path: 'header.png' }) |
Full-page mode includes content below the fold. Element capture is useful for a component or region; the target must be present and visible. If the page loads content as you scroll, allow it to load before capturing, or scroll through it first. Playwright can also return screenshot bytes instead of writing to a path, which is useful when an agent needs to pass the image to another tool. See the Playwright screenshot guide and Playwright emulation guide.
2. Configure Playwright Test or timezone
For a project using Playwright Test, set the locale for the project in playwright.config.js:
import { defineConfig } from '@playwright/test';
export default defineConfig({
use: {
locale: 'fr-FR',
},
});
Or override it for a particular test:
import { test, expect } from '@playwright/test';
test.use({ locale: 'fr-FR' });
test('captures the French-locale page', async ({ page }) => {
await page.goto('https://example.com');
await page.screenshot({ path: 'page-fr.png', fullPage: true });
});
Locale and timezone are independent. If the page must show Paris-local dates or times, configure both:
const context = await browser.newContext({
locale: 'fr-FR',
timezoneId: 'Europe/Paris',
});
This changes the browser’s emulated timezone and locale, not the test runner’s timezone. Configure the runner separately with the TZ environment variable if your test code itself depends on that timezone.
3. Give a browser agent screenshot instructions
If the agent controls Playwright directly, have it create a context with locale: 'fr-FR' before opening the URL, wait for the page to render, and capture the required scope. Check the actual output: a locale setting is a browser signal to the site, not proof that the application selected French content.
With Playwright MCP, the agent-facing browser_take_screenshot tool can capture the viewport, a target element, or the full scrollable page. It supports PNG, JPEG, and WebP and CSS-pixel or device-pixel scale. Full-page capture and a target element are separate choices; the MCP screenshot tool does not combine full-page mode with a target.
Chrome DevTools MCP offers screenshot controls for format, compression quality, maximum width, and maximum height. PNG is the default; JPEG and WebP can reduce the image context size sent into an AI conversation. These output settings do not configure the browser locale. Set fr-FR in the browser session separately.
For a remotely hosted browser session, Cloudflare’s Browser Run is a documented beta route controlled through Chrome DevTools Protocol. It can inspect rendered pages and take screenshots. A local Playwright script is sufficient when the agent can run its own browser; a hosted session is an option when browser execution must be remote.
4. Validate the result and handle edge cases
- Check the page language: inspect visible labels, dates, and the page’s language indicator. Some sites ignore browser locale or prefer a saved user setting.
- Separate locale from region:
fr-FRrequests French as used in France. It does not set geolocation, account country, currency, or a region-specific URL. - Use the right wait condition:
networkidlecan be unsuitable for pages with persistent network activity. If it does not settle, wait for a meaningful selector or use a deliberate short delay before the screenshot. - Handle consent and sign-in: a locale does not bypass consent flows or authentication. Use an authorized test account and establish the desired page state before capture.
- Choose dimensions deliberately: full-page screenshots and device-pixel scaling can produce large images. Use viewport capture or CSS-pixel scale when a smaller visual is sufficient.
- Keep artifacts private: screenshots can contain personal or account data. Store or forward them only where the agent workflow permits.
5. Troubleshooting
| Symptom | Likely cause | Fix |
|---|---|---|
| Page remains in another language | The site uses account preference, URL, cookies, or its own locale logic. | Verify the locale was set before navigation. Use the site’s French URL or supported language control when available, then inspect the rendered page. |
| Dates or times do not match Paris | Locale does not set timezone. | Set timezoneId: 'Europe/Paris' on the browser context as well. |
| Screenshot is blank or incomplete | Navigation failed, the page has not rendered, or content appears after scrolling. | Check navigation errors and response state, wait for a relevant element, and scroll through lazy-loaded sections before full-page capture. |
| Element screenshot fails | The selector matches nothing or the element is hidden. | Wait for the locator to be visible, verify the selector, and capture only after the page reaches the expected state. |
networkidle wait hangs |
Long-lived requests prevent the network from becoming idle. | Use waitUntil: 'domcontentloaded' or 'load', then wait for a page-specific selector or a bounded delay. |
| Browser executable is missing | Playwright package is installed but its browser was not installed. | Run npx playwright install chromium in the environment that runs the agent. |
6. Performance, reliability, and cost
A local browser capture has no screenshot API request fee, but it does require installing and running a browser and managing its resources. Full-page and high-scale captures use more memory and produce larger artifacts than viewport captures. Reuse a browser process for multiple captures when appropriate, but create a fresh context when you need isolated locale, cookies, or state.
For reliability, set a navigation timeout, wait for page-specific readiness, and save screenshots with predictable names. Treat a screenshot as evidence of the rendered state at capture time: dynamic content, personalization, network conditions, and site behavior can change the result. A hosted browser avoids running the browser locally but adds a service dependency and its own configuration.
Or skip the browser setup
ScreenshotNeo is a website screenshot API and MCP server. For a French-locale browser workflow, use Playwright as above when you need to set the browser locale itself. For a one-call screenshot without browser setup, call the API:
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,
)
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}`);
See the ScreenshotNeo API documentation for options and response details. ScreenshotNeo removes cookie banners, popups, and chat widgets before the shot; bot checks, blank pages, and failed loads are never billed. Its MCP server lets AI agents take screenshots. The free plan includes 1,000 screenshots a month with no card, and paid plans start at $5 for 3,000.
Sign up for 1,000 free screenshots a month, with no card required.
FAQ
Does fr-FR translate a website?
No. It emulates browser locale behavior and asks the site to respond accordingly. The site controls whether it serves French content.
Does French locale automatically mean Paris time?
No. Set timezoneId: 'Europe/Paris' separately if the page needs Paris-local time.
Can an AI agent capture only one component?
Yes. With Playwright, use a locator’s screenshot() method; with Playwright MCP, request a target element screenshot.
Can ScreenshotNeo set the browser locale to French?
This guide’s ScreenshotNeo facts do not specify a locale option. Use a browser context configured with Playwright when setting fr-FR is required.


