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.

2 thoughts on “Selenium MouseDownAt MouseMoveAt and MouseUpAt example

  1. 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

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>