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.

cy.drag() & cy.mouse proposal

See original GitHub issue

As mention in the #845 it would be interesting to have a broader API for drag’n drop and mouse movement.

Desired behavior

It’s very hard to reproduce drag’n drop using native browser events. It’s much simpler to simulate how the mouse would behave. Here is a drag’n drop assertion done on nightwatch.js

    let elementToMove = '//div[@class="column"][2]'
    browser
      .url('http://grafikart.github.io/ReorderJS/index.html')
      .useXpath()
      .waitForElementVisible(elementToMove, 1000)
      .moveToElement(elementToMove, 10, 10)
      .mouseButtonDown(0)
      .moveToElement('//div[@class="column"][1]', 10, 10)
      .mouseButtonUp(0)

The API behaves at a lower level where we can control how the mouse behave. It would be nice to have something to describe generic behaviours.

cy.drag(selector: string, position: topLeft|center|topRight...., x: number, y: number)
cy.drag(selector: string, x: number, y: number)
// Maybe
cy.drag(fromSelector: string, toSelector: string) 

// Or a low level api to control the mouse
cy.mouse.moveTo(selector: string)
cy.mouse.press(button = 0)
cy.mouse.moveTo(selector: string)
cy.mouse.release()

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:42
  • Comments:21 (4 by maintainers)

github_iconTop GitHub Comments

12reactions
nwshanecommented, Apr 19, 2018

@jennifer-shehane I’m curious about contributing to this issue, if my company gives me the time to do so. Would you be open to that? Do you have an idea of approximately how long this would take to implement?

6reactions
smart625commented, Jan 16, 2020

@asherccohen Checkout the cypress-drag-drop plugin -> https://github.com/4teamwork/cypress-drag-drop

@bierik This plugin does not work.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to drag and drop in Cypress.io - Stack Overflow
Finally I resolved this issue by using "cy.request". https://docs.cypress.io/api/commands/request.html#Syntax
Read more >
Drag and Drop in Cypress - Automated Visual Testing
Learn how to simulate drag and drop actions in Cypress. ... cy.visit('/ingredients/drag-and-drop'); ... it('should drag ice cream to the order', () => {....
Read more >
trigger | Cypress Documentation
cy.trigger() is meant to be a low-level utility that makes triggering events easier than manually constructing and dispatching them. Since any arbitrary event ......
Read more >
Part 15 - Drag and Drop (Native and mouse drag ... - YouTube
How to work in Cypress with Drag and Drop(DnD)?1. Using Cypress Plugin for Drag and Drop2. Customized methods on JavaScript Drag and Drop ......
Read more >
Cytoscape.js
Note that it does not make sense to disable style if you plan on rendering the graph. Also note that cy.destroy() must be...
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