From 95e934d207fdcfbd624400a630df6634f252a9f0 Mon Sep 17 00:00:00 2001 From: icleitoncosta Date: Mon, 17 Jun 2024 13:17:15 -0300 Subject: [PATCH] fix: Fixed emitting events --- src/controllers/browser.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/controllers/browser.ts b/src/controllers/browser.ts index 05c443c30..f87e871c1 100644 --- a/src/controllers/browser.ts +++ b/src/controllers/browser.ts @@ -230,7 +230,17 @@ export async function injectApi( path.join(__dirname, '../../dist/lib/wapi', 'wapi.js') ), }); - onLoadingScreen(page, onLoadingScreenCallBack); + await onLoadingScreen(page, onLoadingScreenCallBack); + // Make sure WAPI is initialized + await page + .waitForFunction(() => { + return ( + typeof window.WAPI !== 'undefined' && + typeof window.Store !== 'undefined' && + window.WPP.isReady + ); + }) + .catch(() => false); } /**