From 836486cfd86ad0898f5426dfdf37f80ff80d20e6 Mon Sep 17 00:00:00 2001 From: CieanYau Date: Sat, 7 Nov 2026 02:44:57 +0800 Subject: [PATCH] keep password editor clicks stable across native scrolling --- tests/review-online-auth.e2e.test.mjs | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/tests/review-online-auth.e2e.test.mjs b/tests/review-online-auth.e2e.test.mjs index ce37315..678d512 100644 --- a/tests/review-online-auth.e2e.test.mjs +++ b/tests/review-online-auth.e2e.test.mjs @@ -141,21 +141,15 @@ for (const width of [320, 390]) { await field.fill(password); await field.press("End"); const point = await field.evaluate((input) => { - const rect = input.getBoundingClientRect(); const style = getComputedStyle(input); - // 长密码滚到末端;点击实际文字编辑区末端,而不是假设按钮应有多少padding。 + // 读取相对输入框 padding box 的编辑区末端;locator 点击会等滚动/布局稳定, + // 不把测量后的绝对坐标误用于已自然滚动的页面。 return { x: style.direction === "rtl" - ? rect.left + - parseFloat(style.borderLeftWidth) + - parseFloat(style.paddingLeft) + - 1 - : rect.right - - parseFloat(style.borderRightWidth) - - parseFloat(style.paddingRight) - - 1, - y: rect.top + rect.height / 2, + ? parseFloat(style.paddingLeft) + 1 + : input.clientWidth - parseFloat(style.paddingRight) - 1, + y: input.clientHeight / 2, overflowing: input.scrollWidth > input.clientWidth, }; }); @@ -164,7 +158,7 @@ for (const width of [320, 390]) { true, "Exercise a scrolled long password", ); - await page.mouse.click(point.x, point.y); + await field.click({ position: { x: point.x, y: point.y } }); assert.equal( await field.getAttribute("type"), "password",