Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/265.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 无法使用量角器拖放_Javascript_Angularjs_Drag And Drop_Protractor - Fatal编程技术网

Javascript 无法使用量角器拖放

Javascript 无法使用量角器拖放,javascript,angularjs,drag-and-drop,protractor,Javascript,Angularjs,Drag And Drop,Protractor,我无法在应用程序中执行拖放功能。但我观察到,dragAndDrop似乎并没有发生。如果我遗漏了什么,有人能检查一下我的功能并帮助我吗 Try-1 Try-2 Try-3 根据Sergey的建议,我已经实现了我的代码,但我仍然无法进行拖放操作 it('verify drag and drop', () => { let dragElement = element(by.css("span[class='drag-icon']"));

我无法在应用程序中执行拖放功能。但我观察到,dragAndDrop似乎并没有发生。如果我遗漏了什么,有人能检查一下我的功能并帮助我吗

Try-1

Try-2

Try-3

根据Sergey的建议,我已经实现了我的代码,但我仍然无法进行拖放操作

    it('verify drag and drop', () => {
        let dragElement = element(by.css("span[class='drag-icon']"));
        let dropElement = element(by.css("div[id='column'] mat-form-field"));
        //my code

        //drag and drop attribute
        dragAndDrop(dragElement,dropElement);
    });
    

function dragAndDrop($element, $destination) {
    return browser
        .actions()
        .mouseMove($element)
        .perform()
        .then(() =>
            browser
                .actions()
                .mouseDown($element)
                .perform()
        )
        .then(() =>
            browser
                .actions()
                .mouseMove($destination)
                .perform()
        )
        .then(() =>
            browser
                .actions()
                .mouseUp()
                .perform()
        );
}
it('verify drag and drop', async () => {
        let dragElement = element(by.css("#listElement"));
        let dropElement = element(by.css(".cdk-drop-list"));
        //my code

        //drag and drop attribute
        await dragAndDrop(dragElement,dropElement);
    });
function dragAndDrop($element, $destination) {
    return browser
        .actions()
        .mouseMove($element)
        .perform()
        .then(() =>
            browser
                .actions()
                .mouseDown($element)
                .perform()
        )
        .then(() =>
            browser
                .actions()
                .mouseMove($destination)
                .perform()
        )
        .then(() =>
            browser
                .actions()
                .mouseUp($destination)
                .perform()
        );
}

这更有意义。函数返回一个您无法解析的承诺

试试这个

    it('verify drag and drop', async () => {
        let dragElement = element(by.css("span[class='drag-icon']"));
        let dropElement = element(by.css("div[id='column'] mat-form-field"));
        //my code

        //drag and drop attribute
        await dragAndDrop(dragElement,dropElement);
    });

最后,我找到了解决办法。应用程序使用角度和材质进行拖放

    it('verify drag and drop', () => {
        let dragElement = element(by.css("span[class='drag-icon']"));
        let dropElement = element(by.css("div[id='column'] mat-form-field"));
        //my code

        //drag and drop attribute
        dragAndDrop(dragElement,dropElement);
    });
    

function dragAndDrop($element, $destination) {
    return browser
        .actions()
        .mouseMove($element)
        .perform()
        .then(() =>
            browser
                .actions()
                .mouseDown($element)
                .perform()
        )
        .then(() =>
            browser
                .actions()
                .mouseMove($destination)
                .perform()
        )
        .then(() =>
            browser
                .actions()
                .mouseUp()
                .perform()
        );
}
it('verify drag and drop', async () => {
        let dragElement = element(by.css("#listElement"));
        let dropElement = element(by.css(".cdk-drop-list"));
        //my code

        //drag and drop attribute
        await dragAndDrop(dragElement,dropElement);
    });
function dragAndDrop($element, $destination) {
    return browser
        .actions()
        .mouseMove($element)
        .perform()
        .then(() =>
            browser
                .actions()
                .mouseDown($element)
                .perform()
        )
        .then(() =>
            browser
                .actions()
                .mouseMove($destination)
                .perform()
        )
        .then(() =>
            browser
                .actions()
                .mouseUp($destination)
                .perform()
        );
}

这已经被@SergeyPleshakov多次回答了,我最初创建了与您的函数相同的函数,但在我将此问题发布到这里之前,它并没有工作。无论如何,我已经尝试了你提到的相同功能,即使不起作用。我看不到行动的动向。有没有检查/实施的地方?看慢拖慢落/老实说,你可能会做很多错事。首先,我要确保定位器是正确的,然后如何调用函数也很重要。我在您的示例中没有看到我的函数。添加你如何使用我的函数和你的观察结果的代码happening@SergeyPleshakov,我已经在我的问题中添加了我尝试使用您的输入的内容。
it('verify drag and drop', async () => {
        let dragElement = element(by.css("#listElement"));
        let dropElement = element(by.css(".cdk-drop-list"));
        //my code

        //drag and drop attribute
        await dragAndDrop(dragElement,dropElement);
    });
function dragAndDrop($element, $destination) {
    return browser
        .actions()
        .mouseMove($element)
        .perform()
        .then(() =>
            browser
                .actions()
                .mouseDown($element)
                .perform()
        )
        .then(() =>
            browser
                .actions()
                .mouseMove($destination)
                .perform()
        )
        .then(() =>
            browser
                .actions()
                .mouseUp($destination)
                .perform()
        );
}