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.43k stars 3.63k forks source link

[Feature] More granular drag and drop API #16437

Open talldan opened 2 years ago

talldan commented 2 years ago

The existing dragAndDrop api is useful, but there are a few use cases that it doesn't fulfil:

For some prior art, puppeteer has a slightly more granular API:

// Requires `page.setDragInterception( true )` in test setup
const dragData = await page.mouse.drag( sourceElementHandle, target );
await page.mouse.dragEnter( target, dragData );
await page.mouse.dragOver( target, dragData );
expect( dropZone ).toBeVisible(); // this line is pseudocode, I don't think puppeteer supports `toBeVisible`.
await page.mouse.drop( target, dragData );

Another idea is an API like:

const { dragTo, drop } = await drag( locator );

or

const { dragTo, drop } = await dragFile( file );

Where the transferData is encapsulated using a closure and doesn't need to be passed to each function.

(credit to @kevin940726 for the latter idea in https://github.com/WordPress/gutenberg/pull/42722)

rwoll commented 2 years ago

Added collecting feedback label. Thanks for the request!

Is this something you'd be interested in working on a PR for? If so, we can iterate on the API to ensure it's something Playwright would accept before starting the implemention.

Thanks!

talldan commented 2 years ago

Is this something you'd be interested in working on a PR for?

Yep, that's a possibility. It'd be a first code contribution, so it would probably need a lot of iteration 😄

delijah commented 1 year ago

Any progress on this?