Drag and drop practice website
Practice reordering a list by drag and drop, plus the other widgets that rearrange themselves: tabs and an accordion. Open the admin users screen
Drag to reorderDrag a row onto another. The good list also has move buttons.
Built well
Built to break
TabsThe fragile tabs change order on v2.
Built well
Built to break
Accordion
Built well
Built to break
How to locate Drag and drop
Drag and drop is several APIs pretending to be one
There are two kinds of drag and drop on the web. Native HTML5 drag and drop fires dragstart, dragover and drop events; many libraries ignore those and track mouse or pointer events instead. A test tool that sends the wrong kind moves the pointer but nothing drops. This list uses native drag and drop.
Support varies by tool. Playwright’s dragTo handles native drag and drop in Chromium. Selenium’s dragAndDrop sends mouse events, which native drag and drop ignores in Chrome, so Selenium tests usually dispatch the drag events from JavaScript or use a keyboard alternative. Cypress has no drag command; tests trigger the events with a shared DataTransfer.
After a drag, positions change by design. A test that says “the second row” points at a different row after one move. Find rows by what they are, through a test id or their text.
Tabs and accordions hide content until opened, and inactive panels are often not in the DOM at all. The fragile tabs here also change order on v2, so a positional tab locator opens the wrong panel.
What a stable locator looks like
Find rows by test id and verify the order by reading names, not positions. Prefer a keyboard or button alternative when the app offers one; the good list has “Move up” and “Move down” for each row. Open tabs and accordion sections by their role and name, then assert on the panel.
await page.getByTestId('drag-gift-guide').dragTo(page.getByTestId('drag-summer-sale'));
// Without a mouse: the list's move buttons
await page.getByRole('button', { name: 'Move Best sellers up' }).click();
await page.getByRole('tab', { name: 'Specs' }).click();
await expect(page.getByRole('tabpanel')).toContainText('200 gsm');
await page.getByRole('button', { name: 'Returns' }).click();
await expect(page.getByRole('region', { name: 'Returns' })).toBeVisible();In a real workflow
The admin’s users screen has a support rota you reorder by dragging, and the settings screen groups its options in an accordion. Sign in and move someone to the top of the rota.
COR Lens generates locators for shadow DOM, iframes and tables, and grades each one. Click the drag and drop above with it and compare its pick with yours.
Add to Chrome