question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Feature] drag and drop

See original GitHub issue

Drag and drop should work with playwright. Using the existing mouse apis should generate working dragstart, drag, and drop events. There should also be new APIs to simulate dropping in external content, and to inspect content dragged from the web page.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:41
  • Comments:21 (3 by maintainers)

github_iconTop GitHub Comments

13reactions
krokofantcommented, Jul 24, 2021

@bsteffensTempus I was missing some clear documentation as well and I implemented this based on the new features:

async dragDrop(originSelector: string, destinationSelector: string) {
	const originElement = await this.page.waitForSelector(originSelector);
	const destinationElement = await this.page.waitForSelector(destinationSelector);

	await originElement.hover();
	await this.page.mouse.down();
	const box = (await destinationElement.boundingBox())!;
	await this.page.mouse.move(box.x + box.width / 2, box.y + box.height / 2);
	await destinationElement.hover();
	await this.page.mouse.up();
}

or this more standalone

async dragDrop(page: Page, originSelector: string, destinationSelector: string) {
	const originElement = await page.waitForSelector(originSelector);
	const destinationElement = await page.waitForSelector(destinationSelector);

	await originElement.hover();
	await page.mouse.down();
	const box = (await destinationElement.boundingBox())!;
	await page.mouse.move(box.x + box.width / 2, box.y + box.height / 2);
	await destinationElement.hover();
	await page.mouse.up();
}

For reference in 1.13.0 we have page.dragAndDrop() https://github.com/microsoft/playwright/releases/tag/v1.13.0 https://playwright.dev/docs/next/api/class-page/#page-drag-and-drop

7reactions
lind-eduardcommented, Mar 17, 2021

Want to bring this topic up…Are there any progress on this?

Read more comments on GitHub >

github_iconTop Results From Across the Web

HTML Drag and Drop API - W3Schools
Drag and drop is a very common feature. It is when you "grab" an object and drag it to a different location. Browser...
Read more >
Drag and drop - Patterns - Human Interface Guidelines - Design
Using drag and drop, people can move or duplicate selected photos, text, and other content by dragging the selection from one location to...
Read more >
Drag and drop - Wikipedia
In computer graphical user interfaces, drag and drop is a pointing device gesture in which the user selects a virtual object by "grabbing"...
Read more >
HTML Drag and Drop API - MDN Web Docs
HTML Drag and Drop interfaces enable applications to use drag-and-drop features in browsers. The user may select draggable elements with a ...
Read more >
Use this hidden iPhone feature to drag-and-drop files, photos ...
The drag-and-drop feature on iOS 15 allows you to quickly send a link via text message or add a photo attachment to an...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found