Home > other >  Puppeteer cant find element with matching id user[real_name]
Puppeteer cant find element with matching id user[real_name]

Time:11-13

await page.$eval('#user[real_name]', el => el.value = realName);

That is my code and even tho when I inspect the element I see the correct ID puppeteer says it cant find it why? Is it because of the brackets?

CodePudding user response:

I assume you meant to use the == instead ot the single =

await page.$eval('[id="user[real_name]"]', el => el.value == realName);

CodePudding user response:

Okay so if anyone has a problem the reason is the brackets So just change the code to this:

await page.$eval('[id="user[real_name]"]', (el, realName) => el.value = realName, realName);
  • Related