I'm having trouble with a button on my page that opens a popup in a new tab. I have set up a listener to capture the URL of the popup when it opens:
page.on('popup', async popup => {
console.log('popup => ' + await popup.url());
})
The issue is that the website initially opens the popup with an "about:blank" link, and only later loads the actual URL.
To try and solve this problem, I attempted to wait for a few seconds before retrieving the URL, but it still resulted in an empty string being returned:
page.on('popup', async popup => {
await page.waitForTimeout(10000);
console.log('popup => ' + await popup.url());
})
After the main page opens the popup, it changes its URL which makes it difficult for me to access the correct URL associated with the popup.
If you have any suggestions or ideas on how to resolve this issue, I would greatly appreciate it! Thank you.