keep password editor clicks stable across native scrolling
This commit is contained in:
1 parent
27d240b41b
commit
836486cfd8
1 file changed
+6
-12
@@ -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",
|
||||
|
||||
Reference in new issue
Block a user