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.

iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more

To test a large upload reliably with Playwright, handle three separate steps: select the file, allow time for the application to process it, and assert the application’s actual completion signal. Playwright can populate a file input; that alone does not prove the server accepted, stored, or processed the dataset.

Select the file through the right Playwright API

For a standard file input, use the locator-based setInputFiles() method. It supports a file path, an array of paths, a directory path when the control supports directory selection, or an in-memory file object with a name, MIME type, and buffer. Passing an empty array clears the selection. See Playwright’s file upload documentation.

Upload a fixture from disk

const upload = page.getByLabel('Upload file');
await upload.setInputFiles('tests/fixtures/dataset.csv');

An accessible locator such as getByLabel() is preferable to brittle selectors. For a multi-file input, pass an array of paths:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
await page.getByLabel('Upload files').setInputFiles([
  'tests/fixtures/part-1.csv',
  'tests/fixtures/part-2.csv',
]);

Use an in-memory file for small generated fixtures

await page.getByLabel('Upload file').setInputFiles({
  name: 'sample.csv',
  mimeType: 'text/csv',
  buffer: Buffer.from('id,valuen1,examplen'),
});

This can simplify small test cases. For genuinely large datasets, prefer a representative file prepared on disk: holding a large buffer in the test process can increase memory use. Plan fixture creation and cleanup as part of the test setup.

Handle a file chooser created by a click

Some interfaces create the file input only after the user clicks an upload control. Start waiting for the chooser before clicking, so the event is not missed:

const chooserPromise = page.waitForEvent('filechooser');
await page.getByRole('button', { name: 'Choose file' }).click();
const chooser = await chooserPromise;
await chooser.setFiles('tests/fixtures/dataset.csv');

Playwright documents this event-based approach alongside direct input selection. Check the API against the Playwright version installed in your project, especially if relying on version-sensitive /docs/next/ references.

Allow enough time for the whole upload workflow

Playwright Test documents a default test timeout of 30,000 ms and a default assertion timeout of 5,000 ms. They govern different things: increasing the test timeout does not automatically increase the assertion timeout. The values are defaults, not recommended budgets for large uploads. See Playwright’s timeout documentation.

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

Set the test timeout to fit the expected end-to-end processing envelope for the application and environment, then set the assertion timeout intentionally for the completion signal. For example:

import { test, expect } from '@playwright/test';

test('uploads a large dataset', async ({ page }) => {
  test.setTimeout(120_000);
  // Select the file and trigger the application's upload flow.
  await page.getByLabel('Upload file').setInputFiles('tests/fixtures/dataset.csv');
  await page.getByRole('button', { name: 'Upload' }).click();

  await expect(page.getByRole('status')).toHaveText('Upload complete', {
    timeout: 90_000,
  });
});

The numbers in this example are illustrative settings, not Playwright requirements; choose values based on the application’s expected behavior. The locator API notes that setInputFiles() has no timeout by default unless a default or action timeout is configured. The test runner’s overall timeout remains a separate limit. See the Locator API reference.

Assert a real completion state, not just file selection

After choosing a file, assert something the user can observe that represents completion: for example, a completed status, a success notification, or a result view that appears only after processing. Use Playwright’s retrying web assertions so the check waits for the condition instead of sampling it once. The PlaywrightAssertions reference documents these assertions.

Where the test can verify a server-confirmed result through the application, use that result rather than treating the file chooser or a changed filename as proof of a successful upload. Selection is a browser interaction; acceptance, storage, and processing belong to the application and its server.

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

Avoid fixed sleeps when an assertion can wait for the actual condition. Also avoid using networkidle as a generic readiness signal: Playwright’s API reference discourages it for testing readiness and recommends web assertions instead.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Build a useful large-upload reliability matrix

Playwright does not prescribe a benchmark matrix. To make your tests useful, vary the cases according to the application’s own upload policy and supported behavior:

  • Dataset size, including representative boundary cases defined by the application.
  • File count, including single-file and multi-file selection where supported.
  • Supported file formats and relevant validation-rejection cases.
  • Runtime environment and observed application completion behavior.
  • Recoverable failures as well as successful processing.

Keep the comparison grounded in the target application: record the size, number of files, runtime environment, and completion behavior for each scenario. A longer timeout by itself does not make a test reliable; the test still needs to verify the outcome that matters.

What Playwright does—and does not—guarantee

The cited Playwright documentation describes how to set file inputs and configure timeouts, but does not establish a maximum upload size or promise upload throughput. It also cannot establish that the target server accepted or processed a file merely because the browser selected it. Do not treat a particular dataset size as a Playwright limit, or claim performance without testing the target application in the relevant environment. The available references include stable documentation and /docs/next/ pages, so verify version-sensitive API details against the version in your project.

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.