Skip to content

Instantly share code, notes, and snippets.

@bharathmuddada
Created September 5, 2022 01:03
Show Gist options
  • Save bharathmuddada/0c6c068637d0e2bff458af2263460663 to your computer and use it in GitHub Desktop.
Save bharathmuddada/0c6c068637d0e2bff458af2263460663 to your computer and use it in GitHub Desktop.
C# Selenium program to perform Drag and Drop
public class DragandDrop {
public static void Main(string[] args)
{
new DriverManager().SetUpDriver(new ChromeConfig());
var driver = new ChromeDriver();
driver.Navigate().GoToUrl("http://demo.guru99.com/test/drag_drop.html");
driver.Manage().Window.Maximize();
var sales_button = driver.FindElement(By.XPath("//*[@id='credit1']/a"));
var bank_button = driver.FindElement(By.XPath("//*[@id='credit2']/a"));
var amount_button = driver.FindElement(By.XPath("//*[@id='fourth']/a"));
var debitsideaccount_element = driver.FindElement(By.XPath("//*[@id='bank']/li"));
var debitsideamount_element = driver.FindElement(By.XPath("//*[@id='amt7']/li"));
Actions actions = new Actions(driver);
actions.DragAndDrop(bank_button, debitsideaccount_element).Build().Perform();
actions.DragAndDrop(amount_button, debitsideamount_element).Build().Perform();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment