Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

192
Views
puppeteer/Javascript check for network responses in a loop

Using puppeteer I am trying to achieve something where I can capture network responses on selection of a dropdown item. It does not have to be immediate, we can select all options one after another, and can use network response later as well, as long as it works smoothly.

(async () => {
  const browser = await puppeteer.launch(chromeoptions);
  const page = await browser.newPage();
  page.target().createCDPSession();
  page.setDefaultNavigationTimeout(1000000);
}

async function getAppointmentData() {
  await page.goto('go to the page URL')
  let appointmentData = [];
  await page.waitForSelector(
      "[id*=dropdownId]"
    );

  for (let option of options) {
    // Selecting an option from a dropdown trigger a network call that I need to record
    await page.select(
        "select#dropdownId",
        option?.id
      )

   /* Check for a network call that contains that option?.id or .json?details
      Sample URL >>>> https://abc.test.com/en/10.json?details  [Where 10 is options?id]
   */
  // After All Items in dropdown is selected, Want to insert response [Array of Objects] to an object like:
   appointmentData.push({
     id: options?.id;
     data: [Array of Objects]
    }]

  } // For Loop Ends

  processAppointments(appointmentData )

}

processAppointments(data) {
  /// 
}

getAppointmentData();
})();

I tried using page.on() and other methods but not helpful. can someone please help me out here? been stuck for almost one week.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Your page.on should look something like:

page.on("response", response => {
  let match = response.url().match(/(\d+).json/)
  if(match){
    console.log(`option ${match[1]}`)
  }
})
about 4 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 Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!