13. Event Listeners, Console Errors & Downloads

Intercepting Events & Files

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

// Download verification:
const downloadPromise = page.waitForEvent("download");
await page.getByRole("button", { name: "Export CSV" }).click();
const download = await downloadPromise;
await download.saveAs("test-results/report.csv");

Task

  • Implement isFileSizeValid:
  • 1. Accept sizeBytes number and minSize number.
  • 2. Return true if sizeBytes is greater than or equal to minSize.
πŸ’‘Common doubts
Did you like the problem?
Lesson 13 of 18
JavaScript
Loading code editor…
Next