0

how to trigger .onDragEnter function, like this one

// init

// open page, wait load

const actions = await driver.actions();

const da1 = await driver.findElement(By.css('#todrag > span'));
const da2 = await driver.findElement(By.css('#mydropzone'));

await actions.dragAndDrop(da1, da2).perform();

.dragAndDrop() is not working, same as:

await actions.move({origin: da1}).press().move({origin: da2}).release().perform();

sounds like a bug yet

specially because of my left click after .perform(), it stucks (sometime) & spawns [Draggable 1] item/obj to the my real one mouse icon


#answer

cruisepandey > Are you sure that you are not missing .build.perform()?

.build.perform(); aaTypeError: Cannot read property 'perform' of undefined
.build().perform(); TypeError: actions.dragAndDrop(...).build is not a function
.build.perform(); aaTypeError: Cannot read property 'perform' of undefined
.build().perform(); TypeError: actions.move(...).press(...).move(...).release(...).build is not a function
Vadim
  • 306
  • 1
  • 5
  • 13

2 Answers2

0

it's not very clear what you want to do but I understand da2 click and move!!if you need to find and click go https://selenium-python.readthedocs.io/locating-elements.html#:~:text=find_element_by_class_name-,find_element_by_css_selector,-To%20find%20multiple

Vadim
  • 1
  • 1
0

Please download drag_and_drop_helper.js and then try this:

with open("drag_and_drop_helper.js") as f:
    js = f.read()

driver.execute_script(js + "$('#todrag > span').simulateDragDrop({ dropTarget: '#mydropzone'});")

More explanations can bee read here

Prophet
  • 32,350
  • 22
  • 54
  • 79
  • thank you for reply, ref helps, but your answer is not finished yet; And there are #js tag – Vadim Sep 04 '21 at 20:53