Skip to content

[🐛 Bug]: Actions.dragAndDrop not working #16404

@Neutrino666

Description

@Neutrino666

Description

duplicate => #15529 (comment)
with required labels => #15529 (comment)
I-issue-template I-question help wanted G-* R-awaiting answer

What happened?
During the call of Actions.dragAndDrop, if the mouse cursor changes, Selenium will stop in the action and wait for the draggable element to be touched again to continue.

I would like Selenium to complete the drag and drop, independantly of the cursor hypothetical state.

How can we reproduce the issue?

<style> #draggable { background-color: orange; width: 100px; height: 100px; border-radius: 5px; }
    #dropzone {
        background-color: gray;
        width: 150px;
        height: 150px;
        border-radius: 5px;
        position: relative;
    }
</style>

Draggable

Drop Zone

<script>
    function dragStartHandler(ev) {
        ev.dataTransfer.setData("text/plain", ev.target.id);
    }
    
    function dragoverHandler(ev) {
        ev.preventDefault();
        ev.dataTransfer.dropEffect = "move";
    }
    
    function dropHandler(ev) {
        ev.preventDefault();
        const data = ev.dataTransfer.getData("text/plain");
        const draggableElement = document.getElementById(data);

        if (ev.target.id === "dropzone") {
            ev.target.appendChild(draggableElement);
        }
    }
    
    window.addEventListener("DOMContentLoaded", () => {
        const element = document.getElementById("draggable");
        element.addEventListener("dragstart", dragStartHandler);
        element.addEventListener("dragend", dragEndHandler);
    });
</script>

Java code:
// i let you create the driver
driver.navigate().to("path/to/file.html");

    WebElement draggable = driver.findElement(By.id("draggable"));
    WebElement dropZone = driver.findElement(By.id("dropzone"));

    new Actions(driver)
            .dragAndDrop(draggable, dropZone)
            .perform();

    // will not move

Relevant log output
none
Operating System
Windows 10

Selenium version
Java 4.36

What are the browser(s) and version(s) where you see this issue?
MSEdge v.112.0.1722.48

What are the browser driver(s) and version(s) where you see this issue?
MSEdgeWebDriver-11.0.1722.48

Are you using Selenium Grid?
No

Reproducible Code

WebElement draggable = driver.findElement(By.id("draggable"));
    WebElement dropZone = driver.findElement(By.id("dropzone"));

    new Actions(driver)
            .dragAndDrop(draggable, dropZone)
            .perform();

    // will not move

ℹ️ Last known working version: 4.36

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-javaJava BindingsD-chromeI-defectSomething is not working as intendedJ-awaiting answerQuestion asked of user; a reply moves it to triage again

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions