如何在量角器中对HTML 5执行拖放 [英] How to perform drag and drop on HTML 5 in Protractor
问题描述
我正在尝试使用HTML 5 canvas在有角度的应用程序中执行拖放操作.量角器中的dragAndDrop方法不起作用.尽管它可以在jQuery Draggable界面上使用.
I am trying to perform a drag and drop action in an angular app with HTML 5 canvas. The method dragAndDrop in protractor doesn't work on it . Although it works on jQuery Draggable interface.
我尝试通过计算窗口大小来做到这一点,但仍然无法正常工作
I tried doing it in by calculating window size but it still doesn't work
var w = 0;
var h = 0;
browser.executeScript(function () {
var width = $(window).width();
var height = $(window).height();
return { width: width, height: height };
}).then(function (size) {
w = size.width;
h = size.height;
console.log('***1**** width + height *********' + w + ' + ' + h);
browser.wait(protractor.ExpectedConditions.invisibilityOf(element(by.className('bodyLoader'))), sync.maxTimeToLook);
var control = element(by.xpath(labelLocator));
browser.actions().dragAndDrop(
control, { x:w/2, y: h/2 }
).perform();
});
我四处搜寻,发现了这个问题 https://github.com/SeleniumHQ/selenium-google- code-issue-archive/issues/3604
I searched around and found this issue https://github.com/SeleniumHQ/selenium-google-code-issue-archive/issues/3604
我尝试了许多解决方案和许多辅助功能,例如:
I've tried many solutions and many helper functions like:
https://gist.github.com/SirLenz0rlot/cc5baa5a73f188f62f6f
https://gist.github.com/druska/624501b7209a74040175
当前存在一个问题在此处发布.
推荐答案
从 https://github.com/angular/protractor/issues/123
browser.actions().mouseDown(el).perform(); browser.actions().mouseMove({x:0, y:100}).perform(); browser.actions().mouseDown(el).perform(); browser.actions().mouseMove({x:0, y:75}).perform(); browser.actions().mouseUp().perform();
browser.actions().mouseDown(el).perform(); browser.actions().mouseMove({x:0, y:100}).perform(); browser.actions().mouseDown(el).perform(); browser.actions().mouseMove({x:0, y:75}).perform(); browser.actions().mouseUp().perform();
这篇关于如何在量角器中对HTML 5执行拖放的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!