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

Fill and submit the form, wait for the result that proves the submission finished, then call page.screenshot(). For an in-page confirmation, wait for that message; for a predictable redirect, wait for its URL. A click by itself does not prove the application has finished processing the form.

Install Playwright and prepare the browser

This example uses Playwright’s test assertion package to wait for a visible confirmation. Replace the sample URL, field label, button name, and confirmation text with values that match your page.

  1. In a new project directory, initialize npm and install Playwright and its test assertion package:

    npm init -y
    npm install playwright @playwright/test
    npx playwright install chromium

    Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
    #1 Best Overall
    Elebase USB to USB C Adapter for iPhone 18 Pro Max,USBC Car Charger Adapter
    • Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
    • Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
    • Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
    • Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
    • 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.
  2. Save the following as capture-after-submit.js, then run it with node capture-after-submit.js.

const { chromium } = require('playwright');
const { expect } = require('@playwright/test');

(async () => {
  const browser = await chromium.launch();
  try {
    const page = await browser.newPage();
    await page.goto('https://example.com/form');

    await page.getByLabel('Email').fill('reader@example.com');
    await page.getByRole('button', { name: /submit/i }).click();

    // Use the success message your application actually displays.
    await expect(page.getByText('Submitted')).toBeVisible();
    await page.screenshot({ path: 'submitted.png' });
  } finally {
    await browser.close();
  }
})();

The script saves submitted.png in the current working directory. The example is a pattern, not a tested interaction with a particular website. The chosen selectors and completion condition must reflect the target form.

Choose the right completion signal

Form updates the current page

Wait for a visible success message or another meaningful state change. The assertion retries until the condition is met or its timeout is reached, so it handles ordinary variation in response time without a fixed sleep.

await expect(page.getByText('Submitted')).toBeVisible();
await page.screenshot({ path: 'submitted.png' });

Use a locator for the application’s real confirmation. If the message appears in a status region, for example, a role-based locator can make the intent clearer: page.getByRole('status').

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #2
Anker USB-C Hub, 5-in-1 USB Hub for Laptops, 4K HDMI Multiport Adapter
  • 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
  • 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
  • Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
  • 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
  • What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.

Form navigates to a known URL

Wait for the destination with page.waitForURL(). Start waiting before clicking so a fast navigation cannot happen before the wait is registered.

const destination = page.waitForURL('**/thank-you');
await page.getByRole('button', { name: /submit/i }).click();
await destination;
await page.screenshot({ path: 'submitted.png' });

Adjust the URL pattern to the actual destination. Playwright’s Page API marks waitForNavigation() deprecated and inherently racy; use waitForURL() when checking navigation.

Use locators that match the form

Prefer user-facing locators such as labels and accessible roles. They express what a person would identify on the page and are generally more resilient than selectors tied to implementation details.

Locator actions wait for actionability, such as the element being available for interaction. That makes arbitrary pauses like waitForTimeout() a poor default for synchronizing ordinary form interactions. If a page has an application-specific delay or asynchronous state, wait for the state that matters instead.

Choose what the screenshot contains and where it goes

Viewport or whole document

By default, the screenshot shows the current viewport. Add fullPage: true to capture the full scrollable document:

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #4
Sale
UGREEN USB to USB C Adapter Combo 4-Pack, 10Gbps USB C Converter Space Gray
  • Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
  • Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
  • Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
  • Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
  • Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft
await page.screenshot({ path: 'submitted-full.png', fullPage: true });

Save a file or keep the image in memory

Pass path to save the screenshot to a file. Without a path, page.screenshot() returns an image buffer that you can pass to another part of your Node.js program:

const image = await page.screenshot();

For example, the buffer can be written with Node’s file system module:

const fs = require('node:fs/promises');
const image = await page.screenshot();
await fs.writeFile('submitted.png', image);
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Troubleshoot common failures

The confirmation assertion times out

Check whether the form actually succeeded and whether the confirmation text or locator matches the rendered page. If submission redirects instead of showing an in-place message, wait for the destination URL rather than an absent confirmation. If it updates the page, identify the state change the application exposes.

The URL wait never resolves

Confirm the form is expected to navigate and that the pattern matches the resulting URL. Forms that update the current document without navigation need an in-page completion condition instead.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Best Value
Anker USB C Hub, 5-in-1 USBC to HDMI Splitter with 4K Display
  • 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
  • Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
  • Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
  • HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
  • What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.

The locator cannot find a field or button

Check the visible label, accessible name, and role in the actual page. Replace the illustrative Email label or Submit button name with the site’s wording. Prefer an accessible locator over a guessed CSS selector when possible.

The screenshot shows the form before submission completes

Move the screenshot call after the success assertion or URL wait. Do not treat completion of click() as proof that server-side work or the visible response has finished.

Browser launch fails

Install the Chromium browser binary for Playwright with npx playwright install chromium. If the browser is installed but execution still fails, check the error output and the environment’s browser requirements.

Or skip the browser setup

If you need a screenshot of a submitted form’s result page without running a browser script yourself, ScreenshotNeo provides a one-request screenshot API. For a page that needs form interaction first, this is not a replacement for Playwright’s fill-and-submit steps; capture the resulting page URL once the application exposes it.

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

For example, take a screenshot of the result page at https://example.com/thank-you with cURL (replace the URL and key):

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

See the ScreenshotNeo API documentation for request options. ScreenshotNeo removes cookie banners, newsletter popups, and chat widgets before capture; bot checks, blank pages, failed loads, timeouts, and cache hits are not billed. Its MCP server gives AI agents screenshot tools, and the free plan includes 1,000 screenshots a month without a card; paid plans start at $5 for 3,000. Sign up for free and get 1,000 screenshots a month with no card.

Frequently Asked Questions

Does Playwright’s screenshot wait for a form submission to finish?

No. Wait for an application-specific confirmation or expected URL before calling `page.screenshot()`.

Can I take a screenshot without saving a file?

Yes. Call `page.screenshot()` without a `path`; it returns an image buffer.

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

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.