Loading page...Загружаем страницу...正在加载页面...
AtlasRepo

Designing reliable uploads for large datasets using Playwright

说明与用途

在 Playwright 中实现大文件分块上传测试,避免将整个文件加载到内存中,控制请求头并重用浏览器会话。

问题

Enterprise UIs upload massive CSVs (5 GB+) by splitting them into 10 MB chunks, sending each chunk with X‑Chunk‑Index and X‑Total‑Chunks headers. Playwright’s page.setInputFiles streams the whole file and hides the HTTP traffic, making it impossible to test the chunked upload flow.

结果

The approach allows testing of 5 GB uploads without loading the full file into RAM, gives full control over headers, and reuses the browser session for authentication.

工作流

  • Navigate to upload page and capture auth cookies
  • Create an async generator that yields 10 MB buffers without persisting a file
  • Configure page.request with the captured cookies as extra HTTP headers
  • Iterate over the generator, sending each chunk with X‑Chunk‑Index and X‑Total‑Chunks headers
  • Assert each chunk response is OK
  • After all chunks, POST to the completion endpoint with fileName and totalChunks
  • Assert the completion response indicates SUCCESS

证据

Can you test a 5 GB CSV upload without loading the whole file into memory?

来源

Use page.request for low‑level HTTP when UI helpers fall short.

来源

No full file in RAM – each chunk is generated on demand.

来源

  • 记录日期: 2026-09-16T08:45:19.564Z