使用量角器拖放不能在不同的浏览器中工作?

时间:2017-07-19 06:24:44

标签: javascript firefox jenkins drag-and-drop protractor

我有以下代码,在本地机器上工作正常,Chrome环境考虑拖放:

browser.actions().dragAndDrop(elem1, elem2).mouseUp().perform();

但是在Firefox浏览器中Jenkins环境中的相同代码抛出错误:

[e2e] [firefox #11-1] [31m    Failed: UnknownError: Cannot release a button when no button is pressed.'UnknownError: Cannot release a button when no button is pressed.' when calling method: [wdIMouse::up]
[e2e] [firefox #11-1]     Build info: version: '2.53.0', revision: '35ae25b', time: '2016-03-15 17:00:58'
[e2e] [firefox #11-1]     System info: host: '6b46e0e227dc', ip: '172.17.0.3', os.name: 'Linux', os.arch: 'amd64', os.version: '3.10.0-327.13.1.el7.x86_64', java.version: '1.8.0_03-Ubuntu'
[e2e] [firefox #11-1]     Driver info: driver.version: unknown[0m
[e2e] [firefox #11-1]   Stack:

2 个答案:

答案 0 :(得分:0)

我的语法错误了:

browser.actions().dragAndDrop(elem1, elem2).mouseUp().perform();

应改为:

browser.actions().dragAndDrop(elem1, elem2).perform();

答案 1 :(得分:0)

如果.mouseUp()已经有.dragAndDrop(),请尝试在/** * Convenience function for performing a "drag and drop" manuever. The target * element may be moved to the location of another element, or by an offset (in * pixels). * @param {!webdriver.WebElement} element The element to drag. * @param {(!webdriver.WebElement|{x: number, y: number})} location The * location to drag to, either as another WebElement or an offset in pixels. * @return {!webdriver.ActionSequence} A self reference. */ webdriver.ActionSequence.prototype.dragAndDrop = function(element, location) { return this.mouseDown(element).mouseMove(location).mouseUp(); }; 之后执行相同操作。

幕后的

dragAndDrop是mouseDown + mouseMove + mouseUp:

git checkout