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