Move the cursor (Drag and Drop)
See original GitHub issueI read the issue #386 but triggering the JavaScript events seem a bit complicated in some situation (when you don’t know the underlying code).
Use case
My goal is to assert a drag’n drop sorting library work as expected : http://grafikart.github.io/ReorderJS/index.html
Current behavior:
I can make my test pass with the electron browser but it will fail on chrome (nothing moves)
cy.visit('http://grafikart.github.io/ReorderJS/index.html')
cy.get('.column:eq(3)').as('toMove')
cy.get('@toMove')
.should('attr', 'data-position', '2')
.trigger('mousedown')
cy.get('.column:eq(2)').trigger('mousemove')
cy.get('@toMove')
.trigger('mouseup')
.should('attr', 'data-position', '1')
How to reproduce:
You can produce a passing test on electron that fails on chrome with this simplified test (default resolution not changed : 1000 x 660)
it('Should sort', function () {
cy.visit('http://grafikart.github.io/ReorderJS/index.html')
cy.get('.column:eq(3)')
.should('attr', 'data-position', '2')
.trigger('mousedown')
.trigger('mousemove', {clientX: 500, clientY: 50})
.trigger('mouseup')
.should('attr', 'data-position', '1')
})
Issue Analytics
- State:
- Created 6 years ago
- Reactions:2
- Comments:46 (8 by maintainers)
Top Results From Across the Web
CSS for grabbing cursors (drag & drop) - Stack Overflow
I have a JavaScript webapp where the user needs to grab the background to move the whole screen around. So I ...
Read more >Drag'n'Drop with mouse events - The Modern JavaScript Tutorial
Taking something and dragging and dropping it is a clear and simple way to do many things, from copying and moving documents (as...
Read more >cursor - CSS: Cascading Style Sheets - MDN Web Docs
Move over this element to see the cursor style. ... Drag & drop, alias, wide arrow pointing up and to the left partially...
Read more >Cursor position on draggable element - CSS-Tricks
Everything works as intended, with one exception…the position of the mouse cursor relative to the active element. The cursor moves to the center ......
Read more >
Top Related Medium Post
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Dear great community, i investigated the drag and drop functionality and noticed that it doesnt drop to the targets position. So when the cursor wants to drop it, it drops at the origin position where the element actual was. Workaround is to tell cypress to set all 3 position properties to the new position ->>> Like this for example :
I tried to set only on of them and it failed, tried only one property at a time.
IF you set ALL 3 properties, you will actual get this to work .
If this works for everybody, i recommend cypress team to add this to their documentation.
After too long of trying for me, here’s my solution. Use button 0, not 1, Force every click, don’t forget to click on the target element before mouseup. This will work for some not for others but I hope it helps!