diff --git a/tests/playwright/support/utils/password-confirmation.ts b/tests/playwright/support/utils/password-confirmation.ts index 9524f1f5094f2..0100712d3a144 100644 --- a/tests/playwright/support/utils/password-confirmation.ts +++ b/tests/playwright/support/utils/password-confirmation.ts @@ -16,19 +16,18 @@ export async function handlePasswordConfirmation(page: Page, password = 'admin') try { // Check if the dialog exists within a short timeout - const dialogVisible = await dialog.isVisible({ timeout: 500 }).catch(() => false) - - if (dialogVisible) { - // Fill the password field - await dialog.locator('input[type="password"]').fill(password) - - // Click the confirm button - await dialog.getByRole('button', { name: 'Confirm' }).click() - - // Wait for the dialog to disappear - await dialog.waitFor({ state: 'hidden' }) - } + await dialog.waitFor({ state: 'visible', timeout: 500 }) } catch { // Dialog didn't appear, which is fine - some operations might not require confirmation + return } + + // Fill the password field + await dialog.locator('input[type="password"]').fill(password) + + // Click the confirm button + await dialog.getByRole('button', { name: 'Confirm' }).click() + + // Wait for the dialog to disappear + await dialog.waitFor({ state: 'hidden' }) }