【发布时间】:2020-09-18 13:12:15
【问题描述】:
无法将元素/项目拖到放置区域/容器中
使用的技术/软件:
- IDE:Eclipse
- 测试框架:Selenium
- 语言:Java
- 浏览器:Microsoft Edge - 版本 85.0.564.51
问题:
- 我无法将给定的元素/项目拖到放置区域/容器中(参见图片)
- 我还使用了不同的 Xpath/选择器,即 By-CSS、By-Xpath 或 By-Class
- 似乎元素/项目被选中并移动了一个或两个像素,之后元素/项目冻结并且没有被拖动到下面的放置区域/容器
我的尝试:
-
所以我尝试了不同的拖放功能,如下所示:-
Actions action = new Actions(drv); //Source WebElement sourceLocator = drv.findElement(By.className(Item)); //Destination WebElement targetLocator = drv.findElement(By.cssSelector(DropArea)); //Click -> Hold -> Drag -> Drop action.clickAndHold(sourceLocator).moveToElement(targetLocator) .release() .build() .perform(); -
我也尝试过使用“dragAndDrop 而不是 clickAndHold”
`action.dragAndDrop(sourceLocator, targetLocator).build().perform();`
就像我之前说的,项目/元素被选中 -> 移动一两个像素然后它在容器上方冻结(容器根据功能从下方弹出)
As you can see, the item/element is stuck/frozen right above the drop area
Outcome that is expected - Element has been dragged and dropped (Done manually) in the picture
【问题讨论】:
-
请发布您尝试自动化的网站
标签: java selenium drag-and-drop