0

enter image description

I'm doing automated testing and I want to drag the left document '高级元素' to the canvas cell right in the picture. however what commands I use like drag_and_drop, click and hold. the document is never dragged to the canvas cell.

    drag_1 = gt("//button[@class='mat-icon-button']")
    drag_a = gt("//div[@class='dynamic-container']")
    action.drag_and_drop(drag_1, drag_a).perform()

This is my code to drag drag_1 to drag_a but it's not effective.

Chanda Korat
  • 2,453
  • 2
  • 19
  • 23

1 Answers1

0

Have a look at this answer

To summarise what it says (C#):

Actions builder = new Actions(driver);

Action dragAndDrop = builder.clickAndHold(someElement)
   .moveToElement(otherElement)
   .release(otherElement)
   .build();

dragAndDrop.perform();

In Python this will translate to

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()
Dillanm
  • 876
  • 12
  • 28