Commit 33f0d3cb authored by Marco Cavalli's avatar Marco Cavalli
Browse files

fix: improve error handling for CKEditor initialization and streamline download progress logging

parent 1181aac7
Loading
Loading
Loading
Loading
Loading
+16 −10
Original line number Diff line number Diff line
@@ -25,7 +25,7 @@ const puppeteer = require("puppeteer");
  await client.send("Browser.setDownloadBehavior", {
    behavior: "allow",
    downloadPath,
    eventsEnabled: true
    eventsEnabled: true,
  });
  // Wait for the download to complete (adjust timeout as necessary)
  client.on("Browser.downloadProgress", (e) => {
@@ -36,7 +36,6 @@ const puppeteer = require("puppeteer");
    }
  });


  // Adjust this path to the directory containing your HTML files
  const directoryPath = __dirname;

@@ -59,13 +58,20 @@ const puppeteer = require("puppeteer");
        await page.click(".switch"); // Simulate turning the switch on

        // Wait for CKEditor5 to initialize
        await page.waitForSelector(".ck-editor__editable");
        try {
          const editor = await page.waitForSelector(".ck-editor__editable", {
            timeout: 5000,
          });
          // CKEditor operations here
        } catch (error) {
          console.log("CKEditor not found, skipping editor operations");
          // Continue with other operations
        }

        // Trigger the save/download button
        await page.waitForSelector("#download_btn"); // Adjust selector for your save button
        await page.click("#download_btn"); // Simulate clicking the save button

        
        console.log(`Processed and triggered download for: ${file}`);
      }
    }