我正在进行自动化测试,我想将左侧文档“高级元素”拖动到图片右侧的画布单元格中。但是我使用的命令如drag_and_drop,单击并按住。文档永远不会被拖动到画布单元格。
drag_1 = gt("//button[@class='mat-icon-button']")
drag_a = gt("//div[@class='dynamic-container']")
action.drag_and_drop(drag_1, drag_a).perform()
这是我将drag_1
拖到drag_a
的代码,但它无效。
答案 0 :(得分:0)
总结它所说的内容(C#):
Actions builder = new Actions(driver);
Action dragAndDrop = builder.clickAndHold(someElement)
.moveToElement(otherElement)
.release(otherElement)
.build();
dragAndDrop.perform();
在Python中,这将转换为
click_and_drag = ActionChains(driver)
click_and_drag.click_and_hold(someElement)
click_and_drag.move_to_element(otherElement)
click_and_drag.release(otherElement)
click_and_drag.perform()