name: action-execution-drag-drop
description: Perform a bounded desktop or browser drag-and-drop action using verified source and destination targets, then confirm the resulting state.
metadata:
source: skills/04-action-execution/drag-drop.md
category: 04-action-execution
version: "v2"
Drag and Drop
Category: action-execution
Skill Level: intermediate
Stability: stable
Added: 2026-09
Description
Move an interface object from a verified source location to a verified destination, then confirm the resulting state. Coordinate-only gestures are sensitive to layout changes, so prefer element locators over raw coordinates and always verify the postcondition instead of assuming the gesture succeeded.
Inputs / Outputs
| Direction |
Field |
Type |
Contract |
| Input |
source |
locator or coordinates |
The element to drag; resolved and visible before the gesture |
| Input |
destination |
locator or coordinates |
The drop target; resolved and visible before the gesture |
| Input |
postcondition |
predicate |
A checkable property that must hold after the drop |
| Output |
drop_result |
{dropped, verified} |
Whether the gesture ran and the postcondition held |
| Output |
failure |
string or None |
The specific failure when the drop is not verified |
Procedure
- Resolve the source and destination locators and assert both are visible and enabled before dragging.
- Prefer element-to-element drag APIs over absolute coordinates; if coordinates are unavoidable, re-resolve them immediately before the gesture.
- Check that the destination is not a destructive target (delete zone, external site) without explicit authorization.
- Perform the drag, then evaluate the postcondition against the actual interface state.
- Treat a satisfied postcondition as the only success signal; a completed gesture without a verified state is a failure.
- On failure, restore or report the pre-drag state rather than retrying blindly.
Example
def verified_drag(page, source_sel: str, target_sel: str, expect_attr: tuple[str, str]) -> dict:
source = page.locator(source_sel)
target = page.locator(target_sel)
source.wait_for(state="visible")
target.wait_for(state="visible")
source.drag_to(target)
attr, expected = expect_attr
actual = target.get_attribute(attr)
return {"dropped": True, "verified": actual == expected, "failure": None if actual == expected else f"{attr}={actual}"}
result = verified_drag(
page, "[data-testid='source']", "[data-testid='target']",
expect_attr=("data-state", "received"),
)
print(result)
Related Skills
- Mouse Input
- Screenshot Capture
- Assertion
Failure Modes
- Dragging by stale coordinates after a layout change: re-resolve locators immediately before the gesture.
- Dropping into a destructive target without an explicit authorization boundary.
- Treating a completed gesture as success: only a checked postcondition counts.
- Native (OS-level) drag targets not reacting to synthetic HTML5/pointer events: verify the drop with the actual application state and report the incompatibility instead of forcing retries.
- Untrusted or user-supplied locators executed without validation.
Changelog
- v2 (2026-11): Structural modernization; added the input/output contract table, an explicit procedure, a deterministic verification example, expanded failure modes, and version history.
- v1 (2026-09): Initial entry.
Evidence
Evidence status: implementation guidance only; no benchmark claim is made without reproducible evidence.
1---2name: action-execution-drag-drop-23description: Perform a bounded desktop or browser drag-and-drop action using verified source and destination targets, then confirm the resulting state.4---5---6name: action-execution-drag-drop7description: Perform a bounded desktop or browser drag-and-drop action using verified source and destination targets, then confirm the resulting state.8metadata:9 source: skills/04-action-execution/drag-drop.md10 category: 04-action-execution11 version: "v2"12---13141516# Drag and Drop1718**Category:** `action-execution`19**Skill Level:** `intermediate`20**Stability:** `stable`21**Added:** 2026-092223### Description2425Move an interface object from a verified source location to a verified destination, then confirm the resulting state. Coordinate-only gestures are sensitive to layout changes, so prefer element locators over raw coordinates and always verify the postcondition instead of assuming the gesture succeeded.2627### Inputs / Outputs2829| Direction | Field | Type | Contract |30|---|---|---|---|31| Input | `source` | locator or coordinates | The element to drag; resolved and visible before the gesture |32| Input | `destination` | locator or coordinates | The drop target; resolved and visible before the gesture |33| Input | `postcondition` | predicate | A checkable property that must hold after the drop |34| Output | `drop_result` | `{dropped, verified}` | Whether the gesture ran and the postcondition held |35| Output | `failure` | string or `None` | The specific failure when the drop is not verified |3637### Procedure381. Resolve the source and destination locators and assert both are visible and enabled before dragging.392. Prefer element-to-element drag APIs over absolute coordinates; if coordinates are unavoidable, re-resolve them immediately before the gesture.403. Check that the destination is not a destructive target (delete zone, external site) without explicit authorization.414. Perform the drag, then evaluate the postcondition against the actual interface state.425. Treat a satisfied postcondition as the only success signal; a completed gesture without a verified state is a failure.436. On failure, restore or report the pre-drag state rather than retrying blindly.4445### Example4647```python48def verified_drag(page, source_sel: str, target_sel: str, expect_attr: tuple[str, str]) -> dict:49 source = page.locator(source_sel)50 target = page.locator(target_sel)51 source.wait_for(state="visible")52 target.wait_for(state="visible")53 source.drag_to(target)54 attr, expected = expect_attr55 actual = target.get_attribute(attr)56 return {"dropped": True, "verified": actual == expected, "failure": None if actual == expected else f"{attr}={actual}"}5758result = verified_drag(59 page, "[data-testid='source']", "[data-testid='target']",60 expect_attr=("data-state", "received"),61)62print(result)63```6465### Related Skills6667- [Mouse Input](mouse-input.md)68- [Screenshot Capture](screenshot-capture.md)69- [Assertion](assertion.md)7071## Failure Modes7273- Dragging by stale coordinates after a layout change: re-resolve locators immediately before the gesture.74- Dropping into a destructive target without an explicit authorization boundary.75- Treating a completed gesture as success: only a checked postcondition counts.76- Native (OS-level) drag targets not reacting to synthetic HTML5/pointer events: verify the drop with the actual application state and report the incompatibility instead of forcing retries.77- Untrusted or user-supplied locators executed without validation.7879## Changelog80- v2 (2026-11): Structural modernization; added the input/output contract table, an explicit procedure, a deterministic verification example, expanded failure modes, and version history.81- v1 (2026-09): Initial entry.8283## Evidence8485- https://agentskills.io/specification8687Evidence status: implementation guidance only; no benchmark claim is made without reproducible evidence.