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

There are two different ways to capture video from a URL with browser automation. To record what a visitor sees—including playback, captions, controls, consent steps, and authenticated UI—use Playwright’s browser-context video recording. To obtain the media file delivered by a site, trigger its download control, wait for Playwright’s download event, and save the file before the browser context closes.

A recording is a rendered viewport capture; a download is the site’s source file. Choose recording for evidence of the browser session and downloading for the original file. A URL by itself does not guarantee that either is available: the page may stream media, require a gesture or login, or protect playback with access controls.

Choose the right capture workflow

Goal Use What you get Main requirement
Show exactly what the browser rendered Playwright recordVideo A video of the viewport and browser interactions Keep the page open long enough for playback, then close the context
Keep the media file supplied by the site Playwright download event The file delivered by the site, saved to your path A real download action and any required session credentials
Capture a still image or PDF of a page A screenshot or rendering API PNG, JPEG, WebP, or PDF rather than motion video An API that supports the target page and your required options

Recording follows the browser session, so it can include consent handling, login, clicks, captions, and UI state. Downloading is event-driven and normally finishes faster because it does not have to play the video in a viewport. It also preserves the format and bytes that the site sends rather than producing a visual recording.

Record the rendered browser session with Playwright

Install Playwright

In a new Node.js project, install Playwright and its browser binaries:

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.
npm init -y
npm install playwright
npx playwright install

The following script is a complete example. It records a 1280×720 viewport, waits for the page to load, leaves time for playback, closes the context, and then prints the finished recording’s path.

import { chromium } from 'playwright';

const browser = await chromium.launch();
const context = await browser.newContext({
  recordVideo: {
    dir: 'videos/',
    size: { width: 1280, height: 720 }
  },
  viewport: { width: 1280, height: 720 }
});

const page = await context.newPage();
const video = page.video();

await page.goto('https://example.com/video-page', {
  waitUntil: 'domcontentloaded'
});

// Perform consent, login, or play actions required by the page.
// Example: await page.getByRole('button', { name: /play/i }).click();
await page.waitForTimeout(5000);

// The recording is finalized only when the page or context closes.
await context.close();
const videoPath = await video.path();
console.log(`Saved recording to ${videoPath}`);

await browser.close();

Playwright documents recordVideo.dir and optional dimensions on BrowserContext.newContext. Set the viewport deliberately when output dimensions matter. If you omit dimensions, the output is scaled to fit the configured defaults, which can make the artifact different from the CSS viewport you expected.

Wait for the content you actually need

A fixed delay is useful for a quick demonstration, but a production capture should wait on a meaningful condition. Navigate, handle consent or authentication, start playback, and then wait for a selector, a state change, or a known duration. Do not close the context immediately after clicking Play: the recording is finalized at closure, and closing too soon produces a short or empty artifact.

Keep the Video object returned by page.video(). Calling video.path() before the page or context has closed treats an unfinished artifact as if it were complete. Close the context first, then await the path.

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.

Persist the recording to a chosen location

For a page associated with a recording, page.video().path() returns the path after the page or context is closed. You can also call video.saveAs('path/to/output'); it waits until the page is closed and the video is fully saved. Use a destination outside temporary test directories when another process must consume the file.

Control dimensions, pages, and session state

Viewport and output size

  • Set both viewport and recordVideo.size when you need a predictable output size.
  • Use the same device scale, viewport, and responsive breakpoints that your evidence requires; a mobile layout will produce different controls and captions from a desktop layout.
  • Keep one recording context for the pages that should share cookies and storage state. Each recorded page has its own video artifact.

Consent, login, and interaction

Automation does not bypass access controls. If the player requires a consent button, login, a user gesture, or a one-time code, perform that step through Playwright before recording. For repeatable runs, create an authenticated browser context using the session state your application permits, and avoid placing credentials directly in source code or logs.

Closing order matters

Close the page or browser context before asking for the video path. Then close the browser. This order gives Playwright time to flush the recording. If you terminate the process, kill the browser, or let a CI job time out first, the file may be missing or incomplete.

Use Playwright Test when recordings are test artifacts

Playwright Test’s video setting defaults to off. Its retention modes let you limit storage while retaining useful evidence:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
Sale
Anker USB C Hub, 7in1 Multi-Port USB Adapter, 4K@60Hz USBC to HDMI Splitter
  • Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
  • Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
  • Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
  • Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
  • What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.
Mode Behavior When it fits
on Record every test Audits, demonstrations, or workflows where every run matters
retain-on-failure Keep recordings for failed tests Reducing storage while preserving failure evidence
on-first-retry Record the first retry Investigating intermittent failures without recording every initial run
on-all-retries Record retry attempts Comparing behavior across repeated recovery attempts

Retention affects which artifacts are kept by the test runner; it does not change the requirement to let the browser context close so that a recording can be saved.

Download the underlying video file instead

Use this workflow when the page exposes a genuine download link or button. Start waiting for the event before clicking, then save the completed download to a durable path:

import { chromium } from 'playwright';

const browser = await chromium.launch();
const context = await browser.newContext();
const page = await context.newPage();

await page.goto('https://example.com/video-page', {
  waitUntil: 'domcontentloaded'
});

// Authenticate or accept consent here if the site requires it.
const downloadPromise = page.waitForEvent('download');
await page.getByRole('link', { name: /download/i }).click();
const download = await downloadPromise;

await download.saveAs('downloads/video.mp4');
console.log(`Saved ${download.suggestedFilename()} to downloads/video.mp4`);

await context.close();
await browser.close();

The download event is emitted when a download starts, and saveAs writes the completed file. Downloads associated with a browser context are deleted when that context closes, so save the file while the context is still open. If the click opens a new page instead of a download, wait for that page and inspect its controls; a player URL is not automatically a downloadable file.

Authenticated and protected downloads

A download may depend on the same cookies, headers, or authorization that the browser session uses. Perform login in the context before starting the event wait. If the site only streams media, uses a player without a download control, or enforces DRM, Playwright’s automation primitives do not promise access to an original file. Recording the visible playback may still be possible when you are authorized to do so, but it does not remove the site’s terms, copyright restrictions, or technical protections.

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

Recording versus downloading: practical trade-offs

Question Rendered recording File download
What is captured? Viewport pixels, controls, captions, and interactions Bytes delivered by the site
Timing Requires enough playback time and context closure Completes when the download event and save finish
Output dimensions Controlled by viewport and recording dimensions Inherited from the delivered media file
Authentication Uses the browser session naturally Uses session cookies and headers needed by the download
Storage lifetime Keep the saved video path or call saveAs Save before context closure or the temporary download is deleted

Troubleshoot common failures

No video file appears

  • Cause: The context or page never closed. Fix: await context.close(), then call video.path() or video.saveAs().
  • Cause: The process ended or the browser was killed. Fix: close the context in a finally block and give CI enough time to flush artifacts.
  • Cause: The recording directory does not exist or is not writable. Fix: create it ahead of time and verify the job’s filesystem permissions.

The recording is blank or too short

  • Cause: Capture started before navigation, consent, or playback completed. Fix: wait for the relevant selector or state and allow playback time before closing.
  • Cause: The page requires a click or gesture to start media. Fix: perform the required interaction with a locator before waiting.
  • Cause: The viewport is not the one you intended. Fix: set viewport and recordVideo.size explicitly.

The download event never fires

  • Cause: The control starts streaming or opens a player rather than downloading. Fix: inspect the page’s actual behavior and use recording if you need the rendered playback.
  • Cause: The event wait started after the click. Fix: create page.waitForEvent('download') before clicking.
  • Cause: Authentication or consent blocked the action. Fix: complete those steps in the same browser context first.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Performance, reliability, and operating cost

Video recording consumes storage for every captured viewport and requires the browser to remain alive for the capture duration. Keep recordings only when they are evidence, and use Playwright Test retention modes when failures are the important artifacts. For large batches, reuse browser processes carefully, isolate contexts when cookies must not leak between accounts, and choose deterministic waits instead of unnecessarily long fixed delays.

Downloads are generally more efficient when the site offers them because the browser does not render every frame. They can still fail on expiring links, authentication changes, network interruptions, or server-side limits. Save to a durable path immediately and record the URL, session or job identifier, and final filename in your own logs without exposing secrets.

Or skip the browser setup

If you need a clean still image or PDF of the video page rather than a motion recording, ScreenshotNeo can capture the rendered page with one request. It is not a video recorder and will not produce the original media file, but it can remove page clutter before taking a still: cookie and consent banners, newsletter popups, and chat widgets are removed before the shot. Bot checks, blank pages, failed loads, and cache hits are not billed, and the response identifies the result with X-Page-Verdict and X-Billed headers. Its MCP server lets Claude, Cursor, and other MCP clients use take_screenshot, get_page_info, and capture_pdf.

Use the ScreenshotNeo documentation for the full option set. A basic still capture looks like this:

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
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}`);

The free plan includes 1,000 screenshots a month with no card. Paid plans start at $5 for 3,000 shots, and every feature is included on every plan. Create a free ScreenshotNeo account to try it.

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.

Respect permissions and access controls

Browser automation does not grant a license to copy, store, or redistribute a video. Capture only content you are authorized to use, follow the site’s terms and access controls, and check copyright and applicable law before sharing recordings or downloaded files. Playwright’s mechanics explain how to automate the browser; they do not provide permission to reproduce protected media.

Frequently Asked Questions

Can one browser context record several tabs?

Yes. Create multiple pages in the same context when they should share that context’s cookies and storage. Each recorded page has its own video artifact; keep each page reference and close the context only after all required pages finish.

What if the page has playback but no download button?

A player can stream media without exposing a downloadable file. In that case, use a rendered recording if you are authorized to capture the playback; do not assume the player URL is the original media file.

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.