title: Drag and drop not working using Actions when draggable=true using Selenium and C#
body: <p><a href="https://i.stack.imgur.com/9bpRI.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/9bpRI.png" alt="enter image description here"></a></p>
  
  <p>Elements are identified correctly and i can see mouse moving between this two elements but drag and drop not happening.
  Ui not displayed any highlights when click and hold.
  No errors also.</p>
  
  <p>I have tried different solutions suggested on different discussions none of them working for me </p>
  
  <p>My code</p>
  
  <pre><code>_actions = new Actions(Driver.WebDriver);
          var dragAndDrop = _actions.ClickAndHold(parentRow)
                                    .MoveToElement(childRow )
                                    .Release(target)
                                    .Build();
          dragAndDrop.Perform();
          Driver.Wait();
  </code></pre>
  
  <p>This is how i am identifying elements</p>
  
  <pre><code> var childList =Driver.WebDriver.FindElements(By.ClassName("itl-treeNode-title"));
       var parentRow = childList.FirstOrDefault(x =&gt; x.Text.Equals(parentSrc)).FindElement(By.XPath("following-sibling::*[1]"));
       var childRow = childList.FirstOrDefault(x =&gt; x.Text.Equals(childSrc)).FindElement(By.XPath("following-sibling::*[1]"));
  </code></pre>
  
  <p>Same code works on another ui on our application.</p>
  
  <p>I have now changed my code like below and now i am getting stale element exception- Since i need to identify this element dynamically i can not use the POM solution mentioned here <a href="https://www.softwaretestingmaterial.com/stale-element-reference-exception-selenium-webdriver/#How-To-Overcome-Stale-Element-Reference-Exception-in-Selenium" rel="nofollow noreferrer">https://www.softwaretestingmaterial.com/stale-element-reference-exception-selenium-webdriver/#How-To-Overcome-Stale-Element-Reference-Exception-in-Selenium</a></p>
  
  <pre><code>var childList = Driver.WebDriver.FindElements(By.ClassName("itl-treeNode-title"));
       var parent = childList.FirstOrDefault(x =&gt; x.Text.Equals(parentSrc)).FindElement(By.XPath("parent::*"));
       var parentRow = parent.FindElement(By.ClassName("itl-treenode-content-cover"));
       var child = childList.FirstOrDefault(x =&gt; x.Text.Equals(childSrc)).FindElement(By.XPath("parent::*"));
       var childRow = child.FindElement(By.ClassName("itl-treenode-content-cover"));         
       childRow.Click();
       //try
       //{
       //   (new Actions(Driver.WebDriver)).DragAndDrop(childRow, parent).Perform();
       //}         
       //catch (Exception ex)
       //{
       //   throw new Exception("Failed to perform drag and drop ");
       //}
       new Actions(Driver.WebDriver).ClickAndHold(childRow)
                 .MoveToElement(parent)
                 .Release(parent)
                 .Build()
                 .Perform();
       Driver.Wait();
  </code></pre>
  
  <p>Exception</p>
  
  <pre><code>OpenQA.Selenium.StaleElementReferenceException: stale element reference: element is not attached to the page document
    (Session info: chrome=77.0.3865.120)
     at OpenQA.Selenium.Remote.RemoteWebDriver.UnpackAndThrowOnError(Response errorResponse)
     at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters)
     at OpenQA.Selenium.Remote.RemoteWebDriver.PerformActions(IList`1 actionSequenceList)
     at OpenQA.Selenium.Interactions.Actions.Perform()
  </code></pre>