• Jobs
  • About Us
  • professionals
    • Home
    • Jobs
    • Courses and challenges
  • business
    • Home
    • Post vacancy
    • Our process
    • Pricing
    • Assessments
    • Payroll
    • Blog
    • Sales
    • Salary Calculator

0

83
Views
Get popup URL after a new request from javascript on playwright

I have a button on a page that opens a popup (new tab). I can get this popup with a listener:

page.on('popup', async popup => {
       console.log('popup => ' + await popup.url());
    })

The problem is that the website opens it with an "about:blank" link, and later loads an URL.

I tried to wait a few seconds before get the url but it keeps showing a blank string.

page.on('popup', async popup => {
       await page.waitForTimeout(10000);
       console.log('popup => ' + await popup.url());
    })

The main page after opens the popup, changes it URL. So im not able, yet, to get this URL sent to the popup.

Any idea? Thanks!

almost 3 years ago · Juan Pablo Isaza
2 answers
Answer question

0

try to set the url on a const before console.logging

page.on('popup', async popup => {
     await page.waitForTimeout(10000);
     const url = await popup.url()
     console.log('popup => ' + url);
})
almost 3 years ago · Juan Pablo Isaza Report

0

You can wait for navigation of the popup before printing out its url:

page.on('popup', async popup => {
  await popup.waitForNavigation();
  console.log('popup => ' + await popup.url());
})
almost 3 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Our process Sales
Legal
Terms and conditions Privacy policy
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recommend me some offers
I have an error