23. Listening to Browser Events & Managing Files

Browser Events & Download Handling

// Catch console errors:
page.on("pageerror", (error) => {
  console.error("Uncaught exception on page:", error.message);
});

// Download verification:
const downloadPromise = page.waitForEvent("download");
await page.getByRole("button", { name: "Download Invoice" }).click();
const download = await downloadPromise;
await download.saveAs("test-results/invoice.pdf");

Task

  • Implement validateFileSize:
  • 1. Accept sizeBytes number and minBytes number (default 1024).
  • 2. Return sizeBytes >= minBytes.
πŸ’‘Common doubts
Did you like the problem?
Lesson 23 of 35
JavaScript
Loading code editor…
Next