protractor icon indicating copy to clipboard operation
protractor copied to clipboard

HTML5 dragging does not always work on Chrome

Open bartvanherck opened this issue 12 years ago • 31 comments

Following test case:

describe('Drag materials', function() {
    ptor = protractor.getInstance();
    beforeEach(function() {
        browser.get('http://tombatossals.github.io/angular-leaflet-directive/examples/center-example.html');
    });
    describe('draggable map', function() {
        it('Drag Test', function() {
            var el = element(by.xpath('.//img[contains(@class, "leaflet-tile-loaded")][1]'));
            ptor.actions().dragAndDrop(el.find(),{x:40,y:40}).perform();
            expect(element(by.model("london.lat")).getAttribute("value")).not.toBe('51.505');
        });
    });
});

The test does not seem to drag the map. There is also no drop possible with the following test page: http://html5demos.com/drag that seems the same problem.

describe('Drag materials', function() {
    ptor = protractor.getInstance();
    beforeEach(function() {
       browser.get('http://html5demos.com/drag');
    });
    describe('draggable map', function() {
        it('Drag Test', function() {
            var item = element(by.xpath('//*/a[@id="one"]'));
            var dest = element(by.xpath('//*/div[@id="bin"]'));
            ptor.actions().dragAndDrop(el.find()dest.find()).perform();
            ptor.sleep(6000);
        });
    });
});

The drag and drop does even not work with mouseevents:

describe('Drag materials', function() {
    ptor = protractor.getInstance();
    beforeEach(function() {
       browser.get('http://html5demos.com/drag');
    });
    describe('draggable map', function() {
        it('Drag Test', function() {
            var item = element(by.xpath('//*/a[@id="one"]'));
            var dest = element(by.xpath('//*/div[@id="bin"]'));
            ptor.actions().mouseMove(item.find()).
                mouseDown(item.find()).
                mouseMove(dest.find()).
                mouseUp(dest.find()).
                perform();
            ptor.sleep(6000);
        });
    });
});

bartvanherck avatar Mar 06 '14 12:03 bartvanherck

There's some webdriver weirdness around drag and drop - let's pass these along to the webdriver team. Which browser are you using?

juliemr avatar Mar 06 '14 18:03 juliemr

I use Chrome latest version. Did you raise an error report to the webdriver team? Or do I still have to do it ?

bartvanherck avatar Mar 06 '14 20:03 bartvanherck

I have a set of webdriver-related things to look into - I'll add it to my list and take care of it.

juliemr avatar Mar 06 '14 23:03 juliemr

I found an issue in selenium https://code.google.com/p/selenium/issues/detail?id=3604 Looks like it is the same problem.

bartvanherck avatar Mar 07 '14 06:03 bartvanherck

The mouse movements seem to work for both the dragAndDrop and chained mouseDown mouseMove actions. But none of the HTML5 drag events (dragstart, dragend, dragover, dragenter, dragleave, and drop) are firing. This is using the Chrome driver.

boxertech avatar Mar 18 '14 16:03 boxertech

@juliemr Looks like this issue still exists. I am not able to drag and drop an element in chrome browser. The same code works fine in firefox. If you can help me it would be really great. I am using protractor v1.0 and latest chrome browser.

vkkaruna avatar Aug 19 '14 15:08 vkkaruna

Ditto. Drag and drop working fine in Firefox but not in Chrome. Using Chrome 36, Firefox 31. and protractor 1.0.0 with chromedriver.

cristover-lopes avatar Aug 22 '14 15:08 cristover-lopes

I'm having the same problem - Protractor 1.3.1 - Chrome 37.0 - Firefox - 28.

Using the following code to drag and drop

browser.actions().dragAndDrop(slider, {x: amountX, y: amountY}).perform();

On 22 August 2014 16:08, cristover-lopes [email protected] wrote:

Ditto. Drag and drop working fine in Firefox but not in Chrome. Using Chrome 36, Firefox 31. and protractor 1.0.0.

— Reply to this email directly or view it on GitHub https://github.com/angular/protractor/issues/583#issuecomment-53072219.

FuturaITLtd avatar Oct 01 '14 15:10 FuturaITLtd

@hankduan Let's make a test case without using Protractor and add to https://github.com/juliemr/webdriver-bugs

juliemr avatar Oct 02 '14 19:10 juliemr

Is this test case necessary. It seems like it's a known issue documented here: https://code.google.com/p/selenium/issues/detail?id=3604

hankduan avatar Oct 03 '14 18:10 hankduan

Yup, good call. Known issue: https://code.google.com/p/selenium/issues/detail?id=3604

juliemr avatar Oct 03 '14 22:10 juliemr

Still facing this problem on Chrome driver. Any updates if this issue is fixed!!

NehaMG avatar May 19 '15 07:05 NehaMG

Im new to the Protractor -- i have to automate the drag and drop Is there any workaround for this issue please help me on this guys.

ptor = protractor.getInstance(); var item = element.all(by.css('div[dnd-moved="list.splice($index, 1)"]')); var dest = element.all(by.css('div.panel-body')); ptor.actions().mouseMove(item.find()). mouseDown(item.find()). mouseMove(dest.find()). mouseUp(dest.find()). perform(); ptor.sleep(6000);

Lmahalin avatar Oct 09 '15 11:10 Lmahalin

I have the same problem. My test tries to simulate a panning over an svg graph. Besides panning, the graph shows tooltips of values when the mouse passes over its area.

I simplified at the maximum the code to see if something was wrong in accessing the elements. However, when I execute the test, it seems like only mouseover events are fired, since tooltips are shown at the start and end points of the drag.

browser.actions()
    .mouseMove({x: 500, y: 300})
    .mouseDown()
    .mouseMove({x: -500, y: 0})
    .mouseUp().perform();
browser.sleep(3000);

Note: I fixed the window size so the coordinates of the code are correct.

Is there any update on this issue?

davizuku avatar Nov 06 '15 10:11 davizuku

Same issue here!

nvega-ms avatar Nov 26 '15 13:11 nvega-ms

Same issue was this ever resolved?

thewebuiguy avatar Jan 22 '16 09:01 thewebuiguy

+1 need a solution

pidupuis avatar Feb 29 '16 15:02 pidupuis

+1

lopesc avatar Feb 29 '16 17:02 lopesc

Is this the root issue?
https://bugs.chromium.org/p/chromedriver/issues/detail?id=841

keithrz avatar Feb 29 '16 18:02 keithrz

I guess so

pidupuis avatar Mar 01 '16 08:03 pidupuis