'puppeteer cannot get hidden element and also cannnot get the value from hidden element

I failed to use puppeteer to get the value from hidden element.

    browser = await puppeteer.launch({ headless: false })
    page = await browser.newPage( )
    await page.goto("https://www.google.com")
    element = await page.waitForSelector('input[type="hidden"][name="newwindow"]', {
        hidden: true,
        timeout: 15000,
    })
    data = await  page.$eval('input[name="newwindow"]', ({ value }) => value);

I got below error. Can anyone help me?

Uncaught Error: Error: failed to find element matching selector "input[name="newwindow"]"



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source