puppeteer : how can i wait for ajax request and process the result

前端 未结 1 1437
囚心锁ツ
囚心锁ツ 2021-02-05 21:35

so i open a website , waith for all redirects to be done capture captcha image and send it vie nodejs to a user an recive the typed captcha

    const browser =         


        
相关标签:
1条回答
  • 2021-02-05 22:08

    You can wait on both simultaneously and handle whichever occurs first:

    await Promise.race([
      page.waitForNavigation({ waitUntil: "networkidle0" }),
      page.waitForSelector(".Error")
    ]);
    
    if (await page.$(".Error")) {
      // there was an error
    } else {
      // the page changed
    }
    
    0 讨论(0)
提交回复
热议问题