puppeteer : how check if browser is still open and working

前端 未结 3 1675
一向
一向 2020-12-13 11:42

im trying to open multiple tabs in a single browser instance , after they\'re done i close the tabs and then re-opening those tabs every x seconds ... but i want to keep th

3条回答
  •  南笙
    南笙 (楼主)
    2020-12-13 11:55

    If you just close all tabs (or browser window) but browser process is still there (but no any window).

    disconnected event will not be triggered.

    Then you can check whether all tabs are closed by:

            if ((await browser.pages()).length === 0) {
              // no tabs opening, do stuff
            }
    

提交回复
热议问题