navigationPromise resolves once but used multiple times
iofjuupasli opened this issue · 4 comments
iofjuupasli commented
Usually Promise can be resolved only once
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 commented
Have you tried await page.waitForNavigation()
in your navigationPromise constant? Perhaps you could call it like that instead of navigationPromise.
iofjuupasli commented
@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 commented
@iofjuupasli thanks for reporting it. We are currently working to make a better code and selector generation. Will keep you updated!