Drag And Drop in Selenium



Drag And Drop in Selenium C#.

[Test]
public void DragandDrop()
{
        dr.Navigate().GoToUrl("http://demo.guru99.com/test/drag_drop.html");        
        //Element which needs to drag.            
        IWebElement From = dr.FindElement(By.XPath("//*[@id='credit2']/a"));

        //Element on which need to drop.        
        IWebElement To = dr.FindElement(By.XPath("//*[@id='bank']/li"));

        //Using Action class for drag and drop.        
        Actions act = new Actions(dr);

        //Dragged and dropped.        
        act.DragAndDrop(From, To).Build().Perform();
    }
Tags: ,
Leave a comment

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

Subscribe now

Receive weekly newsletter with educational materials, new courses, most popular posts, popular books and much more!