Skip to content

Commit

Permalink
test/e2e/oidc: fix webkit race condition (#1359)
Browse files Browse the repository at this point in the history
This seems to solve intermittent test failures in webkit, where the password was being entered into the username form field.
  • Loading branch information
alxndrsn authored Jan 14, 2025
1 parent 43d8f38 commit 5b32ae0
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions test/e2e/oidc/playwright-tests/src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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);
});
}

0 comments on commit 5b32ae0

Please sign in to comment.