Skip to content

Drag and drop tests stop working in 3.6.0+ #2098

Closed
@pbougie

Description

@pbougie

Capybara Version: 3.6.0
Driver Version: ChromeDriver 2.41.578706
Chrome Version: 69.0.3497.81

I have various drag and drop tests that work fine in version 3.5.1. They simply stop working when Capybara is upgraded to versions 3.6.0, 3.7.0, or 3.7.1.

What has changed? I can't seem to find much information about it.

Activity

twalpole

twalpole commented on Sep 11, 2018

@twalpole
Member

Prior to 3.6.0 all that was generated for drag/drop was mousedown, mousemove, mouseup, in 3.6.0+ Capybara generates HTML5 native drag and drop events for Chrome - 0538cb6 if the element has the HTML5 draggable attribute set to "true". It passes the tests in the Capybara suite for HTML5 drag and drop but it's possible it's missing something - what does your drag and drop use/require and what does the element you're dragging look like?

pbougie

pbougie commented on Sep 11, 2018

@pbougie
Author

I'm dragging <a> elements into <td> elements using the Dragula JS library. I am not using the HTML5 draggable attribute.

Also just tried Firefox Nightly with the same results.

twalpole

twalpole commented on Sep 11, 2018

@twalpole
Member

If the <a> elements don't have a draggable attribute then the behavior should be the same as it was in 3.6.0. In 3.7.0+ there was a change because webdriver compliant drivers no longer automatically scroll elements into view when using the actions API, so I had to implement the scrolling manually. Is the project/page you're testing publicly accessible or can you provide a reproducible example?

twalpole

twalpole commented on Sep 11, 2018

@twalpole
Member

Below is a small ruby snippet that shows drag/drop working on the dragula example site, so if we can figure out what the difference between your usage and the dragula example is it would help narrow this down

require "capybara/dsl"
require 'selenium/webdriver'

sess = Capybara::Session.new(:selenium_chrome)
sess.visit('https://bevacqua.github.io/dragula/')
src = sess.first('#left-defaults > div')
dest = sess.first('#right-defaults > div')
src.drag_to dest
sleep 15 # keep session open so we can see it has dragged

pbougie

pbougie commented on Sep 11, 2018

@pbougie
Author

Unfortunately, it's not publicly accessible. I'll try to put something together to reproduce the problem. Thanks.

twalpole

twalpole commented on Sep 11, 2018

@twalpole
Member

After thinking about this for a while - I know why it's happening. Images and links (the elements you're dragging) default to having the HTML5 draggable="true" . A workaround would be to add a draggable="false" attribute to all the elements you're dragging using dragula (or wrap them in an elements that's not an ) until we can fix this. I guess I need to figure out how to tell whether another library is handling dragging -- hmmmm.

twalpole

twalpole commented on Sep 11, 2018

@twalpole
Member

The draggable="false" workaround won't work due to a bug in Selenium treating draggable as a boolean attribute rather than the enumerated attribute that it is - SeleniumHQ/selenium#6396

pbougie

pbougie commented on Sep 11, 2018

@pbougie
Author

The draggable="false" workaround won't work due to a bug in Selenium treating draggable it as a boolean attribute rather than the enumerated attribute that it is - SeleniumHQ/selenium#6396

I was just trying it before you sent this and it wasn't working.

twalpole

twalpole commented on Sep 11, 2018

@twalpole
Member

@pbougie Please try the drag_link branch and see if that works correctly for you. It should revert to the old dragging behavior if the initial mousedown event is defaultPrevented which dragula should be doing to disable default HTML5 drag and drop. Should only work on Chrome currently -- I'll fix FF too if it works.

pbougie

pbougie commented on Sep 11, 2018

@pbougie
Author

Branch drag_link is working. Thanks.

twalpole

twalpole commented on Sep 12, 2018

@twalpole
Member

drag_link branch should be fixed for FF as well now -- Assuming tests pass I'll merge it into master and 3.7_stable branches and then do a 3.7.2 release tomorrow or Thursday.

twalpole

twalpole commented on Sep 12, 2018

@twalpole
Member

Closing via 195930d

5 remaining items

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @twalpole@pbougie

        Issue actions

          Drag and drop tests stop working in 3.6.0+ · Issue #2098 · teamcapybara/capybara