java - 在硒中拖放时元素会重叠
问题描述
我在拖放 selenium 时遇到问题。实际上我希望将元素放置在不同的位置,但在我的情况下,所有元素在放置时都会重叠。我使用偏移量使用了所有可能的代码集,但最终得到了相同的场景。
Actions actions = new Actions(driver);
Actions action = new Actions(driver);
//1st method
actions.clickAndHold(circle).moveByOffset(555,575).build().perform();
action.release(destination).build().perform();
actions.clickAndHold(rect).moveByOffset(726,598).build().perform();
action.release(destination).build().perform();*/
//2nd method
actions.clickAndHold(circle).moveToElement(destination,331,151).build().perform();
action.release(destination).build().perform();
actions.clickAndHold(rect).moveToElement(destination,584,137).build().perform(); action.release(destination).build().perform(); actions.clickAndHold(src).moveToElement(destination,82,367).build().perform();
action.release(destination).build().perform();
//3rd method
actions.dragAndDropBy(circle, 331, 151);
actions.dragAndDropBy(rect, 584, 137);
actions.build().perform();
//4th method
actions.dragAndDrop(src, destination);
actions.dragAndDrop(rect, destination);
actions.dragAndDrop(圆圈,目的地);action.build().perform();
解决方案
你有没有试过这个方法:
(new Actions(Driver)).DragAndDropToOffset(element, xoffset, yoffset).Perform();
推荐阅读
- python - pytorch 模型不更新
- function - 云函数构建失败
- python - 数据集中的 OWID_WRL 是什么?
- python - 获取 IndexError:列表索引超出范围试图翻译文件
- android - 重构主分支代码时如何合并git分支
- javascript - 样式组件不适用于 create-react-library
- c# - 手机,如何检查被触摸的东西?
- python - 套接字python无法将信息发送到服务器“client.send(name)”
- timescaledb - 如何将历史数据加载到超表中,并让聚合视图拾取它
- android - Android Room:如何从连接表中返回行