Skip to content

[πŸ› Bug]: Actions.dragAndDrop not workingΒ #15529

@Elflodesbois

Description

@Elflodesbois

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?

<head>
    <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>
</head>

<body>
    <div id="draggable" draggable="true"><p>Draggable</p></div>
    <div id="dropzone" ondrop="dropHandler(event)" ondragover="dragoverHandler(event)"><p>Drop Zone</p></div>
    
    <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>
</body>



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.20.0

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-needs-triagingA Selenium member will evaluate this soon!I-defectSomething is not working as intendedJ-staleApplied to issues that become stale, and eventually closed.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions