New to Telerik Test Studio? Download free 30-day trial

How to Drag and Drop

The HTML element wrapper classes make mouse drag & drop operations significantly easier. There are 7 different drag methods defined:

  • public virtual void DragTo(ArtOfTest.WebAii.Controls.HtmlControls.HtmlControl control)

  • public virtual void DragTo(System.Drawing.Point absolutePoint)

  • public virtual void DragTo(int offsetX, int offsetY)

  • public virtual void DragTo(ArtOfTest.WebAii.Controls.HtmlControls.HtmlControl control, ArtOfTest.WebAii.Core.OffsetReference destinationOffsetReference, System.Drawing.Point destinationOffset)

  • public virtual void DragTo(ArtOfTest.WebAii.Core.OffsetReference sourceOffsetReference, System.Drawing.Point

  • sourceOffset, ArtOfTest.WebAii.Controls.HtmlControls.HtmlControl destination)

  • public virtual void DragTo(ArtOfTest.WebAii.Core.OffsetReference sourceOffsetReference, System.Drawing.Point

  • sourceOffset, int destinationOffsetX, int destinationOffsetY)

  • public virtual void DragTo(ArtOfTest.WebAii.Core.OffsetReference sourceOffsetReference, System.Drawing.Point

  • sourceOffset, ArtOfTest.WebAii.Controls.HtmlControls.HtmlControl destination, ArtOfTest.WebAii.Core.OffsetReference destinationOffsetReference, System.Drawing.Point destinationOffset)

Suppose we have an sales by area table that supports drag & drop between cells. We can easily drag & drop the contents of one cell to another cell like this:

// Find the sales table HtmlTable salesTable = Find.ById("area_1_table");

// Drag the data from row 4 to row 3 salesTable.BodyRows[3].Cells[1].DragTo(salesTable.BodyRows[2].Cells[1]);

// Verify the new row subtotals are correct Assert.AreEqual(salesTable.Rows[2].Cells[5].TextContent, "$3342.78"); Assert.AreEqual(salesTable.Rows[3].Cells[5].TextContent, "$2175.17");

' Find the sales table Dim salesTable As HtmlTable = Find.ById(Of HtmlTable)("area_1_table")

' Drag the data from row 4 to row 3 salesTable.BodyRows(3).Cells(1).DragTo(salesTable.BodyRows(2).Cells(1))

' Verify the new row subtotals are correct Assert.AreEqual(salesTable.Rows(2).Cells(5).TextContent, "$3342.78") Assert.AreEqual(salesTable.Rows(3).Cells(5).TextContent, "$2175.17")

In this article