Wednesday 21 December 2011

Selenium with C# - C# code for Drag and Drop

Found this bit of code on Google search  when trying to Automate the Drag and Drop functionality on a web browser-- Thanks for the original coder.

Need to add - using OpenQA.Selenium.Interactions; //(assembly)

IWebElement sourceElement = driver.FindElement(By.CssSelector("li.dimension.attribute")); //Defining the source element to select the filed
IWebElement targetElement = driver.FindElement(By.CssSelector("div.landing-zone")); //Defining the Target element to drop the field
Actions action = new Actions(driver); //
action.DragAndDrop(sourceElement, targetElement).Perform(); //drag&drop

No comments:

Post a Comment