Drag and drop using protractor in dthmlx component

China☆狼群 提交于 2019-12-08 06:26:21

问题


I am using dhtmlx scheduler component with angular. Dhtmlx scheduler You can find drag and drop of events in live demo of Timeline view.

I need to writer protractor test case for it. How can I perform drag and drop of dhtmlx component using protractor?


回答1:


The demos available on the Dhtmlx scheduler page don't use angular. I've found another suitable demo page which I would use as an example.

The general idea is pretty simple - use dragAndDrop() function. Unfortunately it is not documented on the API documentation page. May be this is because it is coming from webdriverjs and protractor has nothing to do with it. Anyway, currently, you can find some information and samples here:

  • How to do drag and drop in protractor?
  • actions_spec.js
  • How to test drag & drop functionality in AngularJS e2e testing

Basically you can either move an element by x or y offset to the left or right or top or bottom; or, you can move to an another element.

Here's an example (moving Task #1 by 1000 to the right):

describe("Sample test", function () {
    beforeEach(function () {
        browser.get("http://dhtmlx.github.io/angular-gantt-demo/");
        browser.waitForAngular();
    });

    it("should move the task", function () {
        var task = element(by.xpath('//div[@class="gantt_bars_area"]//div[@task_id="2"]'));

        browser.actions().dragAndDrop(
            task,
            {x:1000, y:0}
        ).perform();

        browser.sleep(10000);
    });
});

Alternatively, you can manually chain mouseDown(), mouseMove(), mouseUp() actions, examples:

  • How to simulate a drag and drop action in protractor?
  • Drag & Drop with Protractor by Repeater


来源:https://stackoverflow.com/questions/27706415/drag-and-drop-using-protractor-in-dthmlx-component

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!