Skip to content

Unable to drag li tags from source list and drop to an empty target list using selenium #7434

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Shebeok opened this issue Jul 26, 2019 · 7 comments
Labels
C-java Java Bindings

Comments

@Shebeok
Copy link

Shebeok commented Jul 26, 2019

I am trying a drag users from one list to another list. The target list is empty. I want to drag the li tags to that empty list. This does not work in either chrome or firefox.

Sample html code to replicate the issue:

<html>
<body>
    <div id="sourceDiv" style="border: thick;border-color: black; border-width: thick;">
    <span>Source</span>
        <ul id="optionList">
            <li><span draggable="true">Option1</span></li>
            <li><span draggable="true">Option2</span></li>
            <li><span draggable="true">Option3</span></li>
            <li><span draggable="true">Option4</span></li>
        </ul>
    </div>
    <div id="targetDiv"  style="border: thick;border-color: black;border-width: thick;">
    <span>Target</span>
        <ul id="optionList">

        </ul>
    </div>
</body>

</html>

I have tried selenium using draganddrop ,clickandHold along with moveToElement .

Using DragandDropMethod:

WebElement source=By.xpath("//div[@id='sourceDiv']//ul//li");
WebElement target=By.xpath("//div[@id='targetDiv']//ul");
Actions actionBuilder = new Actions(driver);
actionBuilder.dragAndDrop(source, target).build().perform();

Using MoveToElement:


WebElement source=By.xpath("//div[@id='sourceDiv']//ul//li");
    WebElement target=By.xpath("//div[@id='targetDiv']//ul");
    Actions actionBuilder = new Actions(driver);
    actionBuilder.clickAndHold(source).moveToElement(target).release().build().perform();


Environment
OS: Windows 7
Browser: Chrome Version:75.0.3770.142, Firefox Quantum Version:68.0.1
Browser Driver version: ChromeDriver 2.43.600210, GeckoDriver 0.23
Language Bindings version: Java 3.141.59

@p0deje p0deje added the C-java Java Bindings label Jul 29, 2019
@Shebeok
Copy link
Author

Shebeok commented Aug 22, 2019

Hi guys,

I am still facing this issue. The JS workaround mentioned in stackoverflow etc doesn't work for me. Any inputs or workarounds would be highly appreciated.

Thanks!

@barancev
Copy link
Member

Sorry, I overlooked this issue.
Please provide an SSCCE (Short, Self Contained, Correct [compilable] example) http://sscce.org/
If you can't provide a link to the page, consider creating a reproducible page on https://jsfiddle.net/

@barancev barancev added the J-awaiting answer Question asked of user; a reply moves it to triage again label Sep 29, 2019
@Shebeok
Copy link
Author

Shebeok commented Oct 24, 2019

Hi @barancev ,
PFA the same html to reproduce the issue. I have added the selenium code snippet used to drag and drop in the first comment. Kindly help.
Dnd.zip

@Shebeok
Copy link
Author

Shebeok commented Oct 30, 2019

Hi @barancev,
Please find the drag and drop example in the below link.
Expected behavior: the span should be dragged and dropped.
Actual behavior: It gets clicked but source is not dropped in the target.
Kindly help. Any inputs or workarounds would be highly appreciated.
sample html page:
https://www.seleniumeasy.com/test/drag-and-drop-demo.html

WebElement source=By.xpath("//span[@draggable='true']");
WebElement target=By.xpath("//div[@id='mydropzone']");
Actions actionBuilder = new Actions(driver);
actionBuilder.dragAndDrop(source, target).build().perform();

@Shebeok
Copy link
Author

Shebeok commented Nov 5, 2019

Hi guys,

I am still facing this issue. Any inputs or workarounds would be highly appreciated.

Thanks!

1 similar comment
@Shebeok
Copy link
Author

Shebeok commented Nov 18, 2019

Hi guys,

I am still facing this issue. Any inputs or workarounds would be highly appreciated.

Thanks!

@AutomatedTester AutomatedTester removed the J-awaiting answer Question asked of user; a reply moves it to triage again label Mar 19, 2020
@AutomatedTester
Copy link
Member

Duplicate of #8003

@AutomatedTester AutomatedTester marked this as a duplicate of #8003 Feb 17, 2021
@github-actions github-actions bot locked and limited conversation to collaborators Sep 5, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
C-java Java Bindings
Projects
None yet
Development

No branches or pull requests

4 participants