webdriverio: [đ Bug]: Drag drop is not working
Have you read the Contributing Guidelines on issues?
- I have read the Contributing Guidelines on issues.
WebdriverIO Version
7.16.13
Node.js Version
v16.13.1
Mode
WDIO Testrunner
Which capabilities are you using?
{
// maxInstances can get overwritten per capability. So if you have an in-house Selenium
// grid with only 5 firefox instances available you can make sure that not more than
// 5 instances get started at a time.
maxInstances: 5,
//
browserName: 'chrome',
acceptInsecureCerts: true
// If outputDir is provided WebdriverIO can capture driver session logs
// it is possible to configure which logTypes to include/exclude.
// excludeDriverLogs: ['*'], // pass '*' to exclude all driver session logs
// excludeDriverLogs: ['bugreport', 'server'],
}
What happened?
I tried to drag $(modelSchemaString.replace(â[MODEL_NAME]â, âCalendarâ)) element and drop to $(â//div[@id=âmfgx-data-flow-diagramâ]â)_ but I could not get success. Adding the dragAndDrop method below for reference
async dragAndDrop() {
var modelSchemaString = "//div[@id='toolbox-stub-[MODEL_NAME]']";
await $(modelSchemaString.replace("[MODEL_NAME]", 'Calendar')).waitForDisplayed({ timeout: 120000 });
const target = await $("//div[@id='mfgx-data-flow-diagram']");
await $(modelSchemaString.replace("[MODEL_NAME]", 'Calendar')).dragAndDrop(target)
await browser.pause(5000)
await $(modelSchemaString.replace("[MODEL_NAME]", 'CalendarEvent')).dragAndDrop(target)
await browser.pause(5000)
}
Element details of source element $(modelSchemaString.replace(â[MODEL_NAME]â, âCalendarâ)) is :

Element details of target element $(â//div[@id=âmfgx-data-flow-diagramâ]â) is :

Element dragging is successful in my case but dropping is not getting success.
What is your expected behavior?
Drag and drop should happen successfully.
How to reproduce the bug.
Added details in What happened section
Relevant log output
No log file was generated.
Code of Conduct
- I agree to follow this projectâs Code of Conduct
Is there an existing issue for this?
- I have searched the existing issues
About this issue
- Original URL
- State: open
- Created 2 years ago
- Comments: 47 (16 by maintainers)
Hello, I found a solution, we must to move after
mouseDownand to move again with1 pointwhen the pointer is on the target.Itâs not wokring for Angualr CDK drag drop. Perform actions and html-dnd also didnât work. can someone let me know how to make this work? Reproducible code.
@all I can see that the drag action selects the element but doesnât move it. what i am doing wrong
it(âLAM SalesTeamRRTâ, async () => { await leadManagement.salesTeamRRT(âA43â, âAutomate1324â); const AboutMe = await $(â//mat-list-item[contains(@id,âAbout Meâ)]â) const AddField = await $(â//div[@id=âcdk-drop-list-0â]â) await browser.actions([ browser.action(âpointerâ) .move({ duration: 2000, AboutMe, x: 1340, y: 230 }) .down({ button: 0 }) //Code Working till this step .move({ duration: 2000, AddField, x: 950, y: 216 }) .up({ button: 0 }) ])
Yes as said I had to use Selenium 3 actions API as the W3C actions API was not working.
@tv2022 do you have a working example for Selenium? I wasnât able to get your code working. I tried the following:
I can see that the drag&drop action selects the element but doesnât move it.
Thanks @christian-bromann but thatâs the problem, it doesnât work even when using performActions. It behaves exactly the same as it does when using dragAndDrop. There are many people in https://github.com/webdriverio/webdriverio/issues/4134 that have the same problem. Iâve tried with many permutations but nothing seems to work. Once pointerDown is fired, mouseMove doesnât seem to work properly anymore. The app being tested is a React app by the way.
performActions() is not working in our app, which uses React. Any working examples or tips?
@iamatharva If this is blocking you, then you can use this in the mean time until we figure out the bug issue. I have used this package and it works pretty well. https://www.npmjs.com/package/html-dnd
I have the same problem. Canât drop a li element (when I drag a li element and try to move it to the 2nd li, itâs not moving, only pressed). I tried different options: dragAndDrop(), performActions(), html-dnd, etc. Nothing helped me.
My capabilities, Iâm using a hub and chrome Version 99.0.4844.51 :