0

I am currently working on 'Drag and Drop' function in selenium with C#. But it seems like the function is not working. The issue is basically the item that i want to drop is selected but after that selenium takes into account where the mouse pointer is located on the page and tries to drop the element there.

Can anybody have an idea of how I can move mouse pointer physically to the specific point?

You can see the methods that I have tried below:

      IWebElement textchoice_Pageelement = Browser.FindElement(By.XPath("TextchoiceXpath"));

                //Page preview where Page elements need to be dropped
                IWebElement PageOverview = Browser.FindElement(By.XPath("PageXpath"));

            int XOffSet = PageOverview.Location.X;
            int YOffSet = PageOverview.Location.Y;

            Actions builder = new Actions(Browser);

                builder.MoveByOffset(XOffSet,YOffSet).Build().Perform();


            builder.ClickAndHold(textchoice_Pageelement);

            builder.Release(PageOverview).Build().Perform();

As a second method that I tried:

Action action= new Action(browser);
action.ClickAndHold(textchoice_PageElement);
action.MoveToElement(PageOverview);
action.release(PageOverview);
action.build();
action.perform();

Thanks

Gizem
  • 1
  • 1
  • 1
    What code have you tried that is not working? Please edit your question to include this information. – CEH Mar 20 '20 at 15:19
  • @Gizem Does [this](https://stackoverflow.com/questions/58955626/angular-drag-drop-with-html5-not-working-through-selenium-and-python/58957607#58957607) or [this](https://stackoverflow.com/questions/44153189/drag-and-drop-not-working-in-selenium-code/44153962#44153962) or [this](https://stackoverflow.com/questions/59205188/drag-and-drop-not-working-using-actions-when-draggable-true-using-selenium-and-c/59211287#59211287) discussion helps you? – undetected Selenium Mar 20 '20 at 16:05

0 Answers0