Repository: puppeteer
Issue: [Feature]: How to enable multiple file downloading on puppeteer chrome
Labels: feature

### Feature description

I want to download files using puppeteer and sometimes if one file downloaidng get delayed I got this kind of notification


![image](https://github.com/puppeteer/puppeteer/assets/134675615/dd2d2904-4f87-4719-88d2-9f67fda70f4a)

Of course I could mannuallly click [Allow], but I want to open the puppeteer test browser with allowed multiple file download settings.

Please let me know how could I archieve this

Here is my current full source code. Please suggest me if you have any solutions to update this code. Thanks

```
const puppeteer = require('puppeteer-extra');
const StealthPlugin = require("puppeteer-extra-plugin-stealth");
const fs = require('fs');

const stealth = StealthPlugin();
puppeteer.use(StealthPlugin());
stealth.enabledEvasions.delete("iframe.contentWindow");

async function delay(ms) {
    return new Promise((resolve) => setTimeout(resolve, ms));
}

const renameFile = async (oldPath, newPath) => {
    return new Promise((resolve, reject) => {
        fs.rename(oldPath, newPath, (err) => {
            if (err) {
                reject(err);
            } else {
                resolve();
            }
        });
    });
};

(async () => {
    const browser = await puppeteer.launch({
        headless: false,
        args: ["--start-maximized"],
        timeout: 6000000,
        protocolTimeout: 6000000,
        defaultViewport: null,
    });
    const page = await browser.newPage();
    await page.goto(
        "https://clerk.clevelandcountyok.com/web/search/DOCSEARCH25S5"
    );
    await page.waitForSelector("#submitDisclaimerAccept");
    await page.click("#submitDisclaimerAccept");

    await page.waitForSelector("#field_RecDateID_DOT_StartDate");
    await page.type("#field_RecDateID_DOT_StartDate", "01/01/1995");

    await page.waitForSelector("#field_RecDateID_DOT_EndDate");
    await page.type("#field_RecDateID_DOT_EndDate", "01/03/1995");

    await page.waitForSelector("#searchButton");
    await page.click("#searchButton");

    await page.waitForSelector(
        "li.ss-search-row.ui-li-static.ui-body-inherit.ui-first-child"
    );

    // Get the number of pages
    let pageNum = await page.$$eval('.selfServiceSearchResultHeaderLeft', divs => {
        let text = divs[1].innerText.split('for ')[1]; // Extract text after 'for'
        return parseInt(text);
    });
    console.log(pageNum);

    // Go to the first element
    const firstElement = await page.$(
        "li.ss-search-row.ui-li-static.ui-body-inherit.ui-first-child"
    );
    await firstElement.click();
    await delay(2000)
    const viewPDF = await page.$(
        "p.selfServiceSearchFullResult.selfServiceSearchResultNavigation"
    );
    await viewPDF.click();


    for (let i = 0; i < pageNum; i++) {
        console.log(i)
        try {
            await page.waitForSelector('#documentIndexingInformation ul li.ui-li-static.ui-body-inherit');

            await delay(2000)
            await page.waitForSelector('iframe.ss-pdfjs-lviewer');
            const elementHandle = await page.$('iframe.ss-pdfjs-lviewer');
            const frame = await elementHandle.contentFrame();
            await frame.waitForSelector('#numPages');

            let buttonSelector = 'button#printCustom';
            await page.waitForSelector(buttonSelector);
            let buttonHandle = await page.$(buttonSelector);
            let buttonHref = await page.evaluate((button) => button.getAttribute('data-href'), buttonHandle);
            console.log(buttonHref);

            const data = await page.evaluate(() => {
                const documentType = document.querySelector('#documentIndexingInformation ul li.ui-li-static.ui-body-inherit')?.innerText;
                const documentNumber = document.querySelector('.doc-viewer tr:nth-child(1) td div:nth-child(3)')?.innerText;
                const recordingDate = document.querySelector('.doc-viewer tr:nth-child(3) td div:nth-child(3)')?.innerText;
                const numberPages = document.querySelector('.doc-viewer tr:nth-child(4) td div:nth-child(3)')?.innerText;
                const documentDate = document.querySelector('.doc-viewer tr:nth-child(5) td div:nth-child(3)')?.innerText;

                const granteesElement = document.querySelectorAll('li.ui-li-static.ui-body-inherit.ui-last-child')[2];
                const granteeElements = granteesElement?.querySelectorAll("div ul li");
                const grantee = [];
                if (granteeElements) {
                    for (const elem of granteeElements) {
                        grantee.push(elem.innerText);
                    }
                }
                const granteeString = grantee.join(', ');

                const grantorElement = granteesElement?.querySelector("tr:nth-child(2) td div:nth-child(2)");
                const grantor = [];
                if (grantorElement?.querySelector("ul")) {
                    const grantorElements = grantorElement.querySelectorAll("ul li");
                    for (const elem of grantorElements) {
                        grantor.push(elem.innerText);
                    }
                } else if (grantorElement) {
                    grantor.push(grantorElement.innerText);
                }
                const grantorString = grantor.join(', ');

                const legalsElement = document.querySelectorAll('li.ui-li-static.ui-body-inherit.ui-last-child')[3];
                const legalElements = legalsElement?.querySelectorAll("tr td div:nth-child(2) ul li");
                const legal = [];
                if (legalElements?.length > 0) {
                    for (const elem of legalElements) {
                        const legalText = elem.innerText;
                        if (legalText.includes('Legal Remarks:')) {
                            legal.push(legalText);
                        }
                    }
                } else if (legalsElement) {
                    const legalText = legalsElement?.querySelector("tr td div:nth-child(2)")?.innerText;
                    if (legalText && !legalText.includes('Documnet Remarks:') && legalText.includes('Legal Remarks:')) {
                        legal.push(legalText);
                    }
                }
                const legalString = legal.join(', ') || "";

                return [documentType, documentNumber, recordingDate, numberPages, documentDate, granteeString, grantorString, legalString];
            });

            data.push(buttonHref)
            console.log(data)

            // Download pdfs part
            let pdfID = data[1];
            console.log(pdfID)
            let pdfURL = `https://clerk.clevelandcountyok.com${buttonHref}`;
            await frame.evaluate(
                (link, downloadedFileName, downloadDelay) => {
                    const a = document.createElement("a");
                    a.href = link;
                    a.download = downloadedFileName;
                    a.style.display = "none";
                    document.body.appendChild(a);
                    a.click();
                    setTimeout(() => {
                        document.body.removeChild(a);
                        resolve();
                    }, downloadDelay);
                    console.log(link, "successfully downloaded!")
                },
                pdfURL,
                `cleveland_${data[0]}_${pdfID}.pdf`,
                20000
            );

            const clickable = await page.$$(
                "a.ui-link.ui-btn.ui-btn-b.ui-btn-inline.ui-shadow.ui-corner-all"
            );

            if (clickable.length > 1) {
                await delay(1000); // Added delay before click to allow element to be ready
                await clickable[1].click();
            }
        } catch (err) {
            console.error("An error occurred during an iteration:", err);
        }
    }
    await browser.close();
})();

```