Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

chore: wheel input in bidi (#32499)

Yury Semikhatskyf3ada9c6540a
diff --git a/packages/playwright-core/src/server/bidi/bidiInput.ts b/packages/playwright-core/src/server/bidi/bidiInput.ts
index e14e90529c..3550051a6a 100644
--- a/packages/playwright-core/src/server/bidi/bidiInput.ts
+++ b/packages/playwright-core/src/server/bidi/bidiInput.ts
@@ -76,7 +76,7 @@ export class RawMouseImpl implements input.RawMouse {
}
async move(x: number, y: number, button: types.MouseButton | 'none', buttons: Set<types.MouseButton>, modifiers: Set<types.KeyboardModifier>, forClick: boolean): Promise<void> {
- // TODO: bidi throws when x/y are not integers.
+ // Bidi throws when x/y are not integers.
x = Math.round(x);
y = Math.round(y);
await this._performActions([{ type: 'pointerMove', x, y }]);
@@ -91,6 +91,19 @@ export class RawMouseImpl implements input.RawMouse {
}
async wheel(x: number, y: number, buttons: Set<types.MouseButton>, modifiers: Set<types.KeyboardModifier>, deltaX: number, deltaY: number): Promise<void> {
+ // Bidi throws when x/y are not integers.
+ x = Math.round(x);
+ y = Math.round(y);
+ await this._session.send('input.performActions', {
+ context: this._session.sessionId,
+ actions: [
+ {
+ type: 'wheel',
+ id: 'pw_mouse_wheel',
+ actions: [{ type: 'scroll', x, y, deltaX, deltaY }],
+ }
+ ]
+ });
}
private async _performActions(actions: bidi.Input.PointerSourceAction[]) {