Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Drag and drop (map panning) with protractor

I'm trying to automatize a drag&drop action with Protractor/Selenium to check that a map based on tiles (leaflet library) is correctly working, but I can't automate the drag&drop action (panning the map).

I have loaded a page with a map, like this one: http://tombatossals.github.io/angular-leaflet-directive/examples/center-example.html

And this protractor test doesn't pan the map, the dragAndDrop action over the selected image doesn't seem work.

describe('Panning map', function() {    
    var ptor, driver;
    beforeEach(function() {        
        ptor = protractor.getInstance();
        browser.get('center-example.html');
        driver = ptor.driver;
    }, 30000);

    it('should update the center value if the map is dragged', function() {
        var el = element(by.xpath('.//img[contains(@class, "leaflet-tile-loaded")][1]'));
        browser.actions().dragAndDrop(el.find(), { x: 40, y: 40 }).perform();
        ptor.sleep(2000);
        expect(element(by.model("london.lat")).getAttribute("value")).toBe('51.505');
        expect(element(by.model("london.lng")).getAttribute("value")).toBe('-1.09');
    });
});

Which can be the reason for a dragAndDrop action not to apply on an example like this?

like image 241
tombatossals Avatar asked Dec 19 '13 18:12

tombatossals


1 Answers

This is a known webdriver issue: https://code.google.com/p/selenium/issues/detail?id=3604

like image 178
hankduan Avatar answered Oct 20 '22 22:10

hankduan