From 5b32ae0de90d0423584de9ef4b48f1d5e8860d77 Mon Sep 17 00:00:00 2001 From: Alex Anderson <191496+alxndrsn@users.noreply.github.com> Date: Tue, 14 Jan 2025 09:39:56 +0300 Subject: [PATCH] test/e2e/oidc: fix webkit race condition (#1359) This seems to solve intermittent test failures in webkit, where the password was being entered into the username form field. --- test/e2e/oidc/playwright-tests/src/utils.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/test/e2e/oidc/playwright-tests/src/utils.js b/test/e2e/oidc/playwright-tests/src/utils.js index bfbaae35d..fc2a59563 100644 --- a/test/e2e/oidc/playwright-tests/src/utils.js +++ b/test/e2e/oidc/playwright-tests/src/utils.js @@ -69,6 +69,11 @@ function assertTitle(page, expectedTitle) { } async function fillLoginForm(page, { username, password }) { + // Wait for autofocus. On webkit, it looks like `autofocus` on the username + // (`login`) field can sometimes steal focus after the `password` field + // locator has been successfully executed. + await sleep(1); + await page.locator('input[name=login]').fill('playwright-' + username); await page.locator('input[name=password]').fill(password); await page.locator('button[type=submit]').click(); @@ -81,3 +86,9 @@ function initTest({ browserName, page }, testInfo) { console.log(level, `[${browserName}:${testInfo.title}]`, msg.text()); }); } + +async function sleep(seconds) { + return new Promise(resolve => { + setTimeout(resolve, seconds * 1000); + }); +}