Drag and drop using protractor in dthmlx component

2019-06-05 23:40发布

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条回答
Rolldiameter
2楼-- · 2019-06-06 00:24

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:

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:

查看更多
登录 后发表回答