How to enter the one-time password that comes to email with puppeteer

Each time the user logs in, they must enter the one-time password they received by email.

I would like to know the best way to fill in automatically when testing these with puppeteer.

My idea is no longer in headless mode.

(async () => {
    const browser = await puppeteer.launch({headless: false});
    const page = await browser.newPage();   
    await page.goto('https://example.com/login/');

    await page.waitForFunction(() => {
        // Wait for it to be entered manually.
        const otp = document.getElementById('one-time-password').value;
        return otp.length !== 6;
    });

   //do something 

    await browser.close();
)}();