title: C# Selenium MoveToElement not working as expected (moving several elements from one ul)
body: <p>I am learning how to use the Actions class at the moment and I have a little trouble with the moving of elements, I am not sure if the problem is in my code or in the webpage that I am using to test. Basicly I want to perform several reorders,</p>
  
  <pre><code>Drag1 -&gt; Drag2
  Drag2 -&gt; Drag1
  Drag3 -&gt; Drag4
  Drag4 -&gt; Drag2
  </code></pre>
  
  <p>So in the end the order of the elements should look like:</p>
  
  <pre><code>Drag1
  Drag4
  Drag2
  Drag3
  Drag5
  </code></pre>
  
  <p>Instead what happens is </p>
  
  <pre><code>Drag1 -&gt; Drag2
  Drag2 -&gt; Drag1
  Drag1 -&gt; Drag2
  Drag2 -&gt; Drag1
  </code></pre>
  
  <p>The first 2 operations are just getting repeated and it does not touch Drag3 and Drag4 at all....</p>
  
  <p>Here is my code:</p>
  
  <pre><code>using OpenQA.Selenium;
  using OpenQA.Selenium.Chrome;
  using OpenQA.Selenium.Interactions;
  using System.Threading;
  
  namespace ConsoleApp4
  {
      class Program
      {
          static void Main(string[] args)
          {
              IWebDriver driver = new ChromeDriver();
              Actions actions = new Actions(driver);
  
              string[] elementIDs =
              {
                  "Drag1",
                  "Drag2",
                  "Drag3",
                  "Drag4",
                  "Drag5"
              };
  
              driver.Navigate().GoToUrl("http://testing.todvachev.com/draganddrop/draganddrop.html");
  
              IWebElement[] elements =
              {
                  driver.FindElement(By.Id(elementIDs[0])),
                  driver.FindElement(By.Id(elementIDs[1])),
                  driver.FindElement(By.Id(elementIDs[2])),
                  driver.FindElement(By.Id(elementIDs[3])),
                  driver.FindElement(By.Id(elementIDs[4]))
              };
  
              MoveElementFromTo(actions, elements[0], elements[1], 0, 5);
              Thread.Sleep(2000);
              MoveElementFromTo(actions, elements[1], elements[0], 0, 5);
              Thread.Sleep(2000);
              MoveElementFromTo(actions, elements[2], elements[3], 0, 5);
              Thread.Sleep(2000);
              MoveElementFromTo(actions, elements[3], elements[1], 0, -5);
  
              Thread.Sleep(5000);
  
              driver.Quit();
          }
  
          static void MoveElementFromTo(Actions actions, IWebElement from, IWebElement to, int x, int y)
          {
              actions.ClickAndHold(from)
                     .MoveToElement(to)
                     .MoveByOffset(x, y)
                     .Release()
                     .Build().Perform();
          }
      }
  }
  </code></pre>