Reputation: 31
Here is my scenario:
My app uses Azure authentication, so it's setup such a way that when i say await page.goto(url,{waitUntil:'condition'})
- it opens the app in a new tab and then it opens a new window which gets the authentication token and closes itself and comes back to the main app page.
Now the problem is the moment this new page opens, puppeteer thinks the execution of this await page.goto(url,{waitUntil:'condition', timeout:60000})
line is done. So it jumps to next line, even though my app has not been loaded yet. I am not sure how can get the instance of the main app page and make it wait until the navigation completes. So i tried the below option, i tried to make all the opened page instances waitForNavigation:
pages = await browser.pages(
pages.forEach(page => {
await page.waitForNavigation({waitUntil: 'networkidle0', timeout: 60000})
})
-This didn't work as well.
Please let me know how can i make the parent page/the page which has my main app waits until the other tab gets the token back to it.
~tia
Upvotes: 1
Views: 527
Reputation: 1225
if you cannot store the login token in the actual page, maybe received as a callback function,
maybe you can make something using
to
if you can check the existence of the token in page,
simply make a while and wait until token has a value.
Upvotes: 1