Errors while Clicking on 'Accept Cookies' button

I have created a function in which the website cookies should be accepted first before the links are scraped. I have taken snapshots before and after the click and on them you can see that everything is fine and actually nothing stands in the way of scraping the links. But I keep getting this error message -> see Terminal logs in picture. This is the website: https://www.battery-kutter.de/main/de/index/catalog

This is the code I am using:

export const handleProductMenu = async (page, crawler, url) => {

    await page.waitForTimeout(4000);
    const button = await page.$('#CybotCookiebotDialogBodyButtonAccept.CybotCookiebotDialogBodyButton');
    if(button){
        await puppeteerUtils.saveSnapshot(page, {key : 'before-click'})
        console.log('clicking on cookies button.')
        await button.click();
    }else{
        console.log('No cookies button.')
    }
    
    await page.waitForTimeout(5000);
    await puppeteerUtils.saveSnapshot(page, {key : 'after-click'})
    
        // 2 sec timeout after the first. 
   
    const listOfLinks = await page.evaluate(() => {
        const listOfLinks = [];
        $('#indexCategories > div > ul.slides.section.group > li').each((index, element) => {
            const jElement = $(element);
            const links = jElement.find('a').attr('href');
            if(links){
                listOfLinks.push(links);
            }
        
        }) 
        return listOfLinks;
    });

    for( const links in listOfLinks){
        let link = links;
        if(link){
            await crawler.addRequests([{
                url: `${link}`,
                label: LABELS.PRODUCT_CATEGORIES,
                
            }])  
        }

    }
}   
image.png
image.png
image.png
Was this page helpful?