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.

HTML5 dragging does not always work on Chrome

See original GitHub issue

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);
        });
    });
});

Issue Analytics

  • State:open
  • Created 10 years ago
  • Reactions:2
  • Comments:31 (7 by maintainers)

github_iconTop GitHub Comments

8reactions
LibuMathewcommented, Mar 21, 2017

Resolved I used the HTML Drag and Drop Simulator from GitHub https://github.com/PloughingAByteField/html-dnd

Working code:

 var dragAndDrop = require('html-dnd').code;
 
 describe('Protractor Drag and Drop', function () {
     it('should drag input to  ___content', function () {
         browser.get('http://127.0.0.1:7000/#/editor');
 
         var draggable = element(by.id('Input'));
         var droppable = element(by.id('___content'));
         var offsetX = 0;
         var offsetY = 0;
 
         browser.executeScript(dragAndDrop, draggable, droppable, offsetX, offsetY);
         browser.sleep(3000);
     });
 });

but offsetX & offsetY not working for me

0reactions
IgorSasovetscommented, Jan 23, 2018

Hi, everyone! I also had the same issue but with Firefox browser. Many actions such as DnD, right mouse button click, .etc don’t work when running test in Firefox. Here is my implementation of these actions: https://github.com/IgorSasovets/protractor-firefox-support . Now I’m still working on it, but there are some methods that can be used for writing e2e tests using protractor. Protractor version: 5.2.0 Firefox: 57.0.4 geckodriver: v0.19.1

Read more comments on GitHub >

github_iconTop Results From Across the Web

HTML5 Drag not working with Chrome if there is a focused ...
The text "My div text" cannot be dragged into the rectangle, neither by repeat attempts, so Chrome blocks dragging for the user. Clicking ......
Read more >
Drag and drop not working - Google Chrome Community
I'm unable to drag and drop search results from the results page into a new tab. However, I'm able to drag external links...
Read more >
Google Chrome's drag drop feature stopped working
Running Chrome as an administrator is causing this problem. Just go to chrome.exe settings and disable it. Restart ...
Read more >
Touch Drag and Drop Isn't Working in Chrome Browser
Fixing Drag-and-Drop · Type "Touch" into the search bar and set the following options to "Enabled". · You will have to relaunch Google...
Read more >
2695 - HTML5 drag and drop is not working - chromedriver
HTML5 drag and drop is not working. Steps to reproduce: 1. Have a python environment with the selenium pip packages installed. 2. Run...
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