From 606fb8c394cd951b5b923c030ef302a28ffd4b3b Mon Sep 17 00:00:00 2001 From: Tim van der Meij Date: Sat, 1 Oct 2022 17:50:58 +0200 Subject: [PATCH] Fix intermittent errors in the "check that first text field has focus" scripting test This commit fixes the "Expected null to equal '401R'" errors that surfaced after the Puppeteer 18 upgrade. Note that even before that this would have been an improvement because it takes some time between scripting being reported ready (i.e., triggering the execution of any OpenActions) and those OpenActions actually completing execution, so it's only safe to check which element is focused if we know an element actually became focused. --- test/integration/scripting_spec.js | 1 + 1 file changed, 1 insertion(+) diff --git a/test/integration/scripting_spec.js b/test/integration/scripting_spec.js index dffef9f76..fa086bfd0 100644 --- a/test/integration/scripting_spec.js +++ b/test/integration/scripting_spec.js @@ -51,6 +51,7 @@ describe("Interaction", () => { await page.waitForFunction( "window.PDFViewerApplication.scriptingReady === true" ); + await page.waitForFunction(`window.document.activeElement !== null`); // The document has an open action in order to give the focus to 401R. const id = await page.evaluate(() => {