Skip to content
This repository has been archived by the owner on Dec 16, 2022. It is now read-only.

navigationPromise resolves once but used multiple times #184

Closed
iofjuupasli opened this issue Dec 15, 2021 · 4 comments
Closed

navigationPromise resolves once but used multiple times #184

iofjuupasli opened this issue Dec 15, 2021 · 4 comments
Labels
🔎 under review Under review process

Comments

@iofjuupasli
Copy link

Usually Promise can be resolved only once

https://github.com/puppeteer/puppeteer/blob/main/experimental/puppeteer-firefox/lib/FrameManager.js#L167-L210

I thought maybe it has some different behavior for waitForNavigation, but didn't found that in puppeteer source code.

So in this example:

const puppeteer = require('puppeteer');
const browser = await puppeteer.launch()
const page = await browser.newPage()
const navigationPromise = page.waitForNavigation()

await page.goto('https://example.com/')

await page.setViewport({ width: 1920, height: 980 })

await page.waitForSelector('.bidi-highlight > .fixed-top > .navbar > .float-right > .btn-link')
await page.click('.bidi-highlight > .fixed-top > .navbar > .float-right > .btn-link')

await navigationPromise

await page.waitForSelector('#use-sso-button')
await page.click('#use-sso-button')

await navigationPromise

await page.waitForSelector('.lCoei > .d2laFc > .tgnCOd > .WBW9sf > .w1I7fb')
await page.click('.lCoei > .d2laFc > .tgnCOd > .WBW9sf > .w1I7fb')

await navigationPromise

await browser.close()

The second and third await navigationPromise do nothing actually

@ChrisPrzR
Copy link

ChrisPrzR commented Dec 17, 2021

Have you tried await page.waitForNavigation() in your navigationPromise constant? Perhaps you could call it like that instead of navigationPromise.

@ianaya89 ianaya89 added the 🔎 under review Under review process label Dec 18, 2021
@iofjuupasli
Copy link
Author

@ChrisPrzR the code is generated by headless-recorder. The idea of waitForNavigation method is that it should called before navigation, and await after navigation begins

@ianaya89
Copy link
Contributor

@iofjuupasli thanks for reporting it. We are currently working to make a better code and selector generation. Will keep you updated!

@ianaya89
Copy link
Contributor

#232

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
🔎 under review Under review process
Projects
None yet
Development

No branches or pull requests

3 participants