From c062552ecb79087622f2f99d50900f03bce23d7c Mon Sep 17 00:00:00 2001 From: Henrik Skupin Date: Thu, 2 Jan 2025 12:27:25 +0100 Subject: [PATCH] chore(bidi): pointerMove action needs to floor fractional values for x and y position. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit For elements that are only 1 pixel in size, rounding can cause the click to occur outside the element’s rect. For example, a 1px div at (8,8) would not be reached if the click is rounded to (9,9). --- packages/playwright-core/src/server/bidi/bidiInput.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/playwright-core/src/server/bidi/bidiInput.ts b/packages/playwright-core/src/server/bidi/bidiInput.ts index cf6770a4794d8..01a359dd12eb3 100644 --- a/packages/playwright-core/src/server/bidi/bidiInput.ts +++ b/packages/playwright-core/src/server/bidi/bidiInput.ts @@ -79,8 +79,8 @@ export class RawMouseImpl implements input.RawMouse { async move(x: number, y: number, button: types.MouseButton | 'none', buttons: Set, modifiers: Set, forClick: boolean): Promise { // Bidi throws when x/y are not integers. - x = Math.round(x); - y = Math.round(y); + x = Math.floor(x); + y = Math.floor(y); await this._performActions([{ type: 'pointerMove', x, y }]); }