Puppeteer[need help uploading picture]

Viewed 15

I'm playing around with puppeteer on my facebook profile but now I hit a roadblock and I don't know what to do from here. I'm new and only started using puppeteer a few days ago.

I want to upload a profile picture to my facebook account but it's uploading the picture into the banner area. Both the banner area and the profile picture share the same selector. I tried using a different selector like an arial label out of a div instead of an input but I get an error: 'Node is not a file input element'

From my understanding it has to be an input but I don't know how to make it unique. Is there a way to have puppeteer go to the second input selector on the page instead of the first one?

Heres my code:

    const file2 = rndFile2();
    await page.waitForSelector('input[type=file]');
    const elementHandle = await page.$("input[type=file]");
    await elementHandle.uploadFile(file2);

Here's an image of the selector: enter image description here

0 Answers
Related