Apify and Crawlee Official Forum

Updated 3 months ago

enqueueLinksByClickingElements help

I have written this code for Puppeteer:
Plain Text
await puppeteerClickElements.enqueueLinksByClickingElements({ forefront: true, selector: 'a.js-color-change' })

But it generates this error:
Plain Text
 Reclaiming failed request back to the list or queue. Expected property `page` to be of type `object` but received type `undefined`
Expected object `page` to have keys `["goto","evaluate"]` in object `options`

Where is the mistake ?
N
P
6 comments
You need to pass the page and requestQueue as well https://docs.apify.com/sdk/js/docs/1.3/api/puppeteer
Plain Text
import { Dataset, createPuppeteerRouter, utils } from 'crawlee';

export const router = createPuppeteerRouter();

router.addHandler('detail', async ({ request,sendRequest, crawler, page, log,  }) => {

    await utils.puppeteer.enqueueLinksByClickingElements({
        page,
        requestQueue: crawler.requestQueue,
        selector: 'a.js-color-change'
        forefront: true
    })

});
Add a reply
Sign up and join the conversation on Discord