Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

303
Views
Puppeteer failed to handle SSO popup only in headless mode ( In non-headless it goes smooth )

My code :

const puppeteer = require('puppeteer');

(async () => {
    const browser = await puppeteer.launch({
        headless: true,
        args : [
            --user-agents='view below'
        ]
    });
    const page = await browser.newPage();
    await page.goto('website that has sso login', {
        waitUntil: 'networkidle0',
    });
    //tried adding or replacing with waitForSelector
    await page.click('#button_to_open_sso_popup');
    const [ popup ] = await Promise.all([
        new Promise((resolve) => page.once('popup', resolve)),
    ]);
    await popup.waitForNavigation({
        waitUntil: 'networkidle0' //tried default load, ...
    });
    //type in email and password to login then do stuff
    await browser.close();
})();;

In non-headless mode it works fine

In headless mode i always get navigation timed out

TimeoutError: Navigation timeout of 30000 ms exceeded
    at C:\Users\DW\node_modules\puppeteer\lib\cjs\puppeteer\common\LifecycleWatcher.js:106:111
    at async FrameManager.waitForFrameNavigation (C:\Users\DW\node_modules\puppeteer\lib\cjs\puppeteer\common\FrameManager.js:167:23)   
    at async Frame.waitForNavigation (C:\Users\DW\node_modules\puppeteer\lib\cjs\puppeteer\common\FrameManager.js:524:16)
    at async Page.waitForNavigation (C:\Users\DW\node_modules\puppeteer\lib\cjs\puppeteer\common\Page.js:1229:16)
    at async handleSSO (C:\Users\DW\Documents\Code Work\puppeteer_test\fptu_schedule_chat_bot\main.js:65:5)
    at async main (C:\Users\DW\Documents\Code Work\puppeteer_test\fptu_schedule_chat_bot\main.js:33:5)

I have went through similar question and tried using these user agents ( not solving my problem ):

    Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36
    Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.157 Safari/537.36
    Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.69 Safari/537.36

I added an issue on github repo if you are interested : https://github.com/puppeteer/puppeteer/issues/7775

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!