简体   繁体   English

与量角器一起拖放不能在其他浏览器中工作?

[英]Drag and drop with protractor not working in different browsers?

I have below code which is working fine in local machine, Chrome environment considering drag and drop: 我有以下代码在考虑拖放的情况下在本地计算机,Chrome环境中运行良好:

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

But the same code throwing error in Jenkins environment in Firefox browser: 但是在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:

I was wrong with syntax: 我的语法有误:

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

Should be changed to: 应更改为:

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

try to do the same without .mouseUp() , in case of .dragAndDrop() already has it. 如果.dragAndDrop()已经拥有它,请尝试在没有.mouseUp()的情况下执行相同的操作。

dragAndDrop behind the scenes is mouseDown + mouseMove + mouseUp: dragAndDrop在幕后是mouseDown + mouseMove + mouseUp:

/**
 * 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();
};

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM