2017-07-19 54 views
0

我有下面这是在本地机器做工精细的代码,铬环境考虑拖拽:使用量角器不能在不同的浏览器中工作拖放?

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

但同样的代码在Firefox浏览器中抛出错误詹金斯环境:

[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: 

任何援助修复将非常感激修复它

回答

0

我是错的语法:

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

应改为:

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

尝试做同样没有.mouseUp(),在.dragAndDrop()已经拥有它的情况。

dragAndDrop幕后是鼠标按下+的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(); 
}; 
+0

@Mithun,请注明你的或我的答案。它会向其他用户显示此问题已回答。 – Oleksii

相关问题