Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use the drag-and-drop method that matches your widget. Cypress has no universal built-in cy.drag() command. For mouse-driven widgets, use cy.trigger() with the event properties your component expects. For file upload zones, use selectFile({ action: 'drag-drop' }). For native HTML5 drag-and-drop that ignores synthetic events, use a CDP-based helper such as cypress-real-dnd. In every case, assert the resulting UI state with a fresh query.

Identify the drag-and-drop model first

“Drag and drop” describes several different browser interactions. Before writing a test, inspect the component and determine which model it implements:

  • Mouse-driven widget: Libraries such as jQuery UI Sortable listen for mouse events and coordinates.
  • Native HTML5 drag-and-drop: An element has draggable="true" and the application handles the browser’s dragstart, dragover and drop pipeline.
  • File drop zone: The application accepts files through a drop target rather than moving a DOM element.
  • Custom pointer implementation: A framework or component may use pointer events, a gesture library or its own event contract.

The receiving handler determines which event properties are required. Cypress describes cy.trigger() as a low-level utility that avoids assumptions about arbitrary events; you must provide the properties expected by the handler, including those from a third-party library.

Prepare selectors and assertions

Use stable, user-facing selectors instead of classes generated by a framework. Add attributes such as data-cy="draggable", data-cy="drop-target" and data-cy="done-item". Keep the source and destination visible so Cypress actionability checks can detect an accidental overlay or off-screen target.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Elebase USB to USB C Adapter for iPhone 18 Pro Max,USBC Car Charger Adapter
  • Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
  • Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
  • Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
  • Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
  • 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.

Capture the initial state, perform the interaction, then query the destination again. Do not treat an event firing as proof that the application accepted the drop.

<li data-cy="draggable">Backlog item</li>
<ul data-cy="drop-target"></ul>

Test a jQuery UI Sortable-style widget with cy.trigger()

Cypress’s documented low-level sequence uses a primary-button mouse press, movement with coordinates, and release:

it('moves an item into the target list', () => {
  cy.get('[data-cy=draggable]').trigger('mousedown', {
    which: 1,
    pageX: 600,
    pageY: 100,
  })

  cy.get('[data-cy=draggable]').trigger('mousemove', {
    which: 1,
    pageX: 600,
    pageY: 600,
  })

  cy.get('[data-cy=draggable]').trigger('mouseup')

  cy.get('[data-cy=drop-target]')
    .find('[data-cy=draggable]')
    .should('contain', 'Backlog item')
})

Why these properties matter

  • which: 1 identifies the primary mouse button expected by this jQuery UI example.
  • pageX and pageY provide document coordinates. Choose points inside the visible source and destination, not merely their edges.
  • The second query is a new Cypress command chain. It verifies the post-drop DOM rather than reusing a subject that may have moved.

Adapt the selectors and coordinates to your application. A component that uses client coordinates, pointer events or a different library may require different properties or a different event sequence. Read the implementation or component documentation when this minimal sequence does not change state.

Test native HTML5 drag-and-drop

Native HTML5 dragging is not the same as dispatching a few mouse events. The browser normally creates a drag data store and emits a sequence including dragstart, repeated dragover events and drop. A synthetic sequence can therefore reach the wrong handler or lack the data the application checks.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

When plain draggable="true" elements, react-dnd, Sortable.js or dnd-kit do not respond to cy.trigger(), consider cypress-real-dnd. Cypress lists it as a community plugin that uses the Chrome DevTools Protocol to trigger the native pipeline. Install and import it according to the package’s current instructions, then use its drag command with your source and target. Pin the version in your project and verify that your Cypress browser and CI setup support its CDP connection.

Rank #2
Anker USB-C Hub, 5-in-1 USB Hub for Laptops, 4K HDMI Multiport Adapter
  • 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
  • 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
  • Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
  • 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
  • What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.

Do not silently substitute a mouse-only test for a native interaction. If the production code depends on dataTransfer, assert the actual application result after the helper runs.

Test a file upload drop zone

For a file drop zone, Cypress provides a built-in simulation. Give selectFile() a fixture and set action: 'drag-drop':

it('uploads a JSON file through the drop zone', () => {
  cy.get('[data-cy=drop-zone]').selectFile(
    'cypress/fixtures/file.json',
    { action: 'drag-drop' },
  )

  cy.get('[data-cy=uploaded-file]')
    .should('be.visible')
    .and('contain', 'file.json')
})

The subject can be any DOM element. If the application listens on document or body, use cy.get('body') as the subject. Cypress accepts a fixture path, an alias, a buffer, or a file object. A file object can specify fileName, mimeType and lastModified:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
cy.get('[data-cy=drop-zone]').selectFile({
  contents: Cypress.Buffer.from('{"ok":true}'),
  fileName: 'result.json',
  mimeType: 'application/json',
  lastModified: Date.now(),
}, { action: 'drag-drop' })

Cypress warns that chaining commands which rely on the subject after selectFile() is unsafe. Re-query the upload status, filename or error message before asserting it.

Use a command-based helper when your component needs one

@4tw/cypress-drag-drop

This community package adds drag and move commands. Install it as a development dependency:

Rank #3
Sale
Anker USB C Hub, 7in1 Multi-Port USB Adapter, 4K@60Hz USBC to HDMI Splitter
  • Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
  • Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
  • Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
  • Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
  • What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.
npm install --save-dev @4tw/cypress-drag-drop

Import the package from your Cypress commands or support file, then call:

cy.get('.sourceitem').drag('.targetitem')

Its options can be split into source and target, and the command yields true or false for the attempt. Treat that value as diagnostic information; still assert the business result in the page.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

cypress-dragndrop-kit

Cypress’s directory also describes this community option for sortable lists, draggable elements and custom UI components. Check its current maintenance, Cypress compatibility and license before adopting it. Community packages can require updates when Cypress, the browser or your drag library changes.

A practical decision guide

Application behavior First choice Important consideration
jQuery UI-style mouse sortable cy.trigger() with mouse properties Supply which and coordinates expected by the widget.
File upload drop zone selectFile({ action: 'drag-drop' }) Re-query after the command; use body for document-level listeners.
Native HTML5 or data-transfer-dependent drag CDP-based helper such as cypress-real-dnd Check browser and CI compatibility and pin the helper version.
Unknown custom implementation Inspect its event handlers, then start with the smallest matching sequence Event names and required properties are library-specific.

Reliable implementation workflow

  1. Classify the interaction. Confirm whether it is a mouse widget, native HTML5 drag or file drop.
  2. Add stable selectors. Mark source, target and the post-drop state with data-cy attributes.
  3. Start with the smallest matching method. Use the documented mouse sequence, built-in file simulation or a native helper as appropriate.
  4. Keep coordinates actionable. Move through visible source and target regions, and let Cypress actionability checks run unless a hidden control is intentional.
  5. Assert the business outcome. Verify list order, destination membership, uploaded filename, success state or validation error.
  6. Stabilize asynchronous UI. Use Cypress’s retryable assertions and wait on a meaningful selector rather than adding arbitrary delays.
  7. Validate in CI. Run the same browser family and viewport assumptions used locally, especially for CDP-based plugins.

Troubleshooting drag-and-drop failures

“The event fires, but nothing moves”

The handler may require coordinates, a primary-button flag, pointer events or a drag data store. Inspect the component’s listener and add only the required properties. For native HTML5 behavior, switch to a CDP-based helper.

“The source is covered or outside the viewport”

Cypress actionability checks are protecting you from a non-user-like interaction. Remove overlays, scroll the source and target into view, or correct the selector. Do not force the command unless the application intentionally tests a hidden element.

Rank #4
Sale
UGREEN USB to USB C Adapter Combo 4-Pack, 10Gbps USB C Converter Space Gray
  • Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
  • Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
  • Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
  • Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
  • Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft

“The file drop test passes intermittently”

Re-query after selectFile() and assert a stable completion indicator. Check that the fixture path, MIME type and application validation rules agree. If the listener is attached to document, target body.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

“A plugin works locally but fails in CI”

Compare Cypress and browser versions, headed versus headless mode, and CDP availability. Pin the plugin, Cypress and browser versions, then run a minimal reproduction in the same CI image.

“The helper reports success but the UI is unchanged”

A command-level success result only indicates that the attempt completed. Assert the resulting list, card location, upload state or server response with a fresh query.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Performance, maintenance and cost considerations

Prefer the smallest interaction that faithfully exercises the component. Synthetic mouse events are usually simpler to maintain for a mouse-only widget; native helpers add setup and browser constraints but are appropriate when the application depends on browser drag semantics. File simulation avoids operating-system automation while still exercising the drop-zone code path.

Keep test data deterministic, use dedicated fixtures, and avoid arbitrary sleeps. When a drag library changes its event contract, update the test method rather than adding more events blindly. Review community package maintenance and licensing as part of dependency upgrades.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Best Value
Anker USB C Hub, 5-in-1 USBC to HDMI Splitter with 4K Display
  • 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
  • Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
  • Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
  • HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
  • What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.

Or skip the browser setup

If you need screenshots of the resulting page rather than an interaction test, ScreenshotNeo provides a website screenshot API and MCP server. A single request captures a PNG, JPEG, WebP or PDF. Cookie and consent banners, newsletter popups and chat widgets are removed before capture; bot checks, blank pages and failed loads are not billed. AI agents can use its MCP tools, including take_screenshot, get_page_info and capture_pdf.

See the complete parameter reference in the ScreenshotNeo documentation. cURL:

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

Python:

import requests
r = requests.get("https://api.screenshotneo.com/v1/shot", params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"}, timeout=90)
open("shot.webp", "wb").write(r.content)

Node.js:

const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);

Responses identify whether a capture was clean or billed through the X-Page-Verdict and X-Billed headers. The free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000 shots. Create a free ScreenshotNeo account to try it.

Frequently Asked Questions

Does Cypress have a built-in cy.drag() command?

No. Cypress provides low-level event triggering through cy.trigger(), built-in file dragging through selectFile(), and community helpers for cases that need native drag behavior.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Which selector should I use for a drag source?

Use a stable attribute such as data-cy on the source, destination and resulting state. Avoid selectors tied to generated class names.

Should I assert that dragstart fired?

Usually no. Assert the user-visible business result—new list order, destination membership, uploaded file or validation message—with a fresh query.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.