title: Selenium WebDriver (C#). Drag and drop of an element into iframe
body: <p>I am using Selenium WebDriver with C# for automation. But recently I faced a problem with dragging an element from outside an iframe and dropping it on another element (or place) inside an iframe. I was trying to perform drag and drop by existing methods of <code>Actions</code> class: (in the examples below <code>source</code> is placed outside the iframe, but <code>target</code> - inside.)</p>
  
  <ol>
  <li><p><code>DragAndDrop(IWebElement source, IWebElement target)</code>. Here I still get a <code>StaleElementException</code> due to needing to switch to <code>iframe</code>.</p></li>
  <li><p><code>DragAndDropToOffset(IWebElement source, int offsetX, int offsetY)</code>. In this case nothing happens at all.</p></li>
  </ol>
  
  <p>I am providing snippet of my code:</p>
  
  <pre><code>var source = Driver.FindElement(By.XPath(
      "//div[@data-window-module-name='Sitemap'];
  var actions= new Actions(Driver);
  Driver.SwitchToFrame("WVTemplateFrame");
  var target = Driver.FindElement(By.XPath("//iframe[@name='WVTemplateFrame']//a");
  Driver.SwitchToDefaultContent();
  actions.DragAndDrop(source, target).Build().Perform();
  [or]
  actions.DragAndDropToOffset(source, 120, 206).Build().Perform();
  </code></pre>
  
  <p>Both examples do not work.  Any help would be appreciated.</p>