Selenium MouseDownAt MouseMoveAt and MouseUpAt example 

Here is an example that tells you how you can use Selenium MouseDownAt MouseMoveAt and MouseUpAt commands to do drag an item from one location and drop the item in another location. I am using the Drag & Drop: Reordering a List example Yahoo Developer Network.
Here is the url for the drag and drop example –

using System;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using NUnit.Framework;
using Selenium;
namespace SeleniumTests
public class Untitled
private ISelenium selenium;
private StringBuilder verificationErrors;
public void SetupTest()
selenium = new DefaultSelenium("localhost", 4444, "*chrome", "");
verificationErrors = new StringBuilder();
public void TeardownTest()
catch (Exception)
// Ignore errors if unable to close the browser
Assert.AreEqual("", verificationErrors.ToString());
public void TheUntitledTest()
selenium.MouseDownAt("//li[@id='li1_1']", "");
selenium.MouseMoveAt("//div[@id='example-canvas']/div[@class='workarea'][2]/ul", "");
selenium.MouseUpAt("//div[@id='example-canvas']/div[@class='workarea'][2]/ul", "");

If you found this solution helpful or have something extra to add, feel free to share it here by commenting below.

Selenium Webdriver Forum -The Online Community for Selenium Webdriver and Selenium RC Users and Professionals
2 responses to “Selenium MouseDownAt MouseMoveAt and MouseUpAt example”
  1. Luke Griffiths says:

    Thanks Pavandeep, this is just what I was looking for. Let’s see if it works now …

  2. Mani says:


    I want to automate the testing of canvas element using selenium…I have tried couple of methods…But, none seemed to work..I am trying for digital signature…Can you please provide some suggestions?



Leave a Reply