I need to automate drag and drop functionality with Telerik controls, I currently use WatiN for my automation (see related quesiton Testing drag-and-drop with Watin on Telerik controls . I am considering if WatiN can't do it, will I able to test drag and drop will if I change to use Selenium 2 instead.

Can this (drag and drop testing in a web applicaiton) be easily achieved with Selenium2 (in C#), ideally without injecting javascript into the application being teseted?

1 Answer 1


While I'm not certain if these mechanisms will specifically work with the Telerik controls (I know it works with jQuery), there are a couple of ways to do this. You can use IRenderedWebElement.DragAndDropOn(), but this method is deprecated. The newer way, which isn't available in a released binary form yet, but is checked into the source tree and will be released in the next binary, is to use the Actions class to create the drag-and-drop action. Your code would look something like the following:

public void DragAndDropExample()
    // driver is an instance of IWebDriver; 
    // elementToDrag and targetElement are instances of IWebElement
    Actions actionsProvider = new Actions(driver);
    actionsProvider.DragAndDrop(elementToDrag, targetElement).Perform();

You can also use the DragAndDropToOffset() method if you want to drag an element to an arbitrary screen location.

  • Excellent! This worked for me. Until the recent versions of the FirefoxDriver I had to try and do it with the legacy Selenium driver and mouseDown/mouseMove commands. I am using the offset method now (note the casing is wrong in the sample above - but an IDE editor should be enough to help assist)
    – user1416
    Commented Oct 6, 2011 at 18:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.