microsoft / playwright

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
https://playwright.dev
Apache License 2.0
66.75k stars 3.66k forks source link

[Feature]: Support the `step` option for the `Locator.dragTo` method #32609

Open romanresh opened 1 month ago

romanresh commented 1 month ago

🚀 Feature Request

By default, the Locator.dragTo method raises one intermediate mousemove event. We need to set the steps option to increase number of intermediate mousemove events as it's implemented in the Mouse.Move method options.

Example

Set the non-default steps option:

await source.dragTo(target, { steps: 3 });

Motivation

There are a few cases:

  1. In some components, dragging starts only after a few intermediate mousemove events with holding mousedown to prevent unintended changes.
  2. Sometimes, during the dragging action some elements should catch dragging above them before dragging is finished on the end point.
dgozman commented 1 month ago

@romanresh While we consider this feature request for prioritization, you can probably work around it by calling page.mouse.down()/move()/up() and passing steps there.

romanresh commented 1 month ago

@romanresh While we consider this feature request for prioritization, you can probably work around it by calling page.mouse.down()/move()/up() and passing steps there.

Yes, thank you, we use this WA in our tests.

It makes tests less stable because the drag event also makes a few checks before performing drag and drop: stabilize element, visibility and others. So, it's also important to call the Locator.dragTo(.., { trial: true }) before down/move/up.

All these actions allow to test our scenarios, but the result trace log contains too much excess information.