From e10a19ed74e851edccf6e88897256a2d98f52804 Mon Sep 17 00:00:00 2001 From: soulkirito <66830063+soulkirito@users.noreply.github.com> Date: Mon, 10 Jan 2022 12:23:42 +0800 Subject: [PATCH] Update PptrToolkit.ts Bug. browser.pages() will return empty array if multiple fakebrowser instances are opened independently. For example, open two fakebrowser instances in Electron app. --- src/core/PptrToolkit.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/core/PptrToolkit.ts b/src/core/PptrToolkit.ts index 144e7c0..b5567ee 100644 --- a/src/core/PptrToolkit.ts +++ b/src/core/PptrToolkit.ts @@ -165,7 +165,11 @@ export class PptrToolkit { const start = new Date().getTime() while (new Date().getTime() - start < timeout) { - const pages = await browser.pages() + const pages = await Promise.all( + browser.targets() + .filter((target) => target.type() === 'page') + .map((target) => target.page()) + ); const arr = [] for (const p of pages) {