public void DragAndDropOnJQueryItems() { driver.Url = droppableItems; IWebElement toDrag = driver.FindElement(By.Id("draggable")); IWebElement dropInto = driver.FindElement(By.Id("droppable")); // Wait until all event handlers are installed. System.Threading.Thread.Sleep(500); Actions actionProvider = new Actions(driver); actionProvider.DragAndDrop(toDrag, dropInto).Perform(); string text = dropInto.FindElement(By.TagName("p")).Text; DateTime endTime = DateTime.Now.Add(TimeSpan.FromSeconds(15)); while (text != "Dropped!" && (DateTime.Now < endTime)) { System.Threading.Thread.Sleep(200); text = dropInto.FindElement(By.TagName("p")).Text; } Assert.AreEqual("Dropped!", text); IWebElement reporter = driver.FindElement(By.Id("drop_reports")); // Assert that only one mouse click took place and the mouse was moved // during it. string reporterText = reporter.Text; Assert.That(reporterText, Does.Match("start( move)* down( move)+ up")); Assert.AreEqual(1, Regex.Matches(reporterText, "down").Count, "Reporter text:" + reporterText); Assert.AreEqual(1, Regex.Matches(reporterText, "up").Count, "Reporter text:" + reporterText); Assert.That(reporterText, Does.Contain("move")); }
public void DragAndDropOnJQueryItems() { driver.Url = droppableItems; IWebElement toDrag = driver.FindElement(By.Id("draggable")); IWebElement dropInto = driver.FindElement(By.Id("droppable")); // Wait until all event handlers are installed. System.Threading.Thread.Sleep(500); Actions actionProvider = new Actions(driver); actionProvider.DragAndDrop(toDrag, dropInto).Perform(); string text = dropInto.FindElement(By.TagName("p")).Text; DateTime endTime = DateTime.Now.Add(TimeSpan.FromSeconds(15)); while (text != "Dropped!" && (DateTime.Now < endTime)) { System.Threading.Thread.Sleep(200); text = dropInto.FindElement(By.TagName("p")).Text; } Assert.AreEqual("Dropped!", text); IWebElement reporter = driver.FindElement(By.Id("drop_reports")); // Assert that only one mouse click took place and the mouse was moved // during it. string reporterText = reporter.Text; Assert.IsTrue(Regex.IsMatch(reporterText, "start( move)* down( move)+ up")); Assert.AreEqual(1, Regex.Matches(reporterText, "down").Count, "Reporter text:" + reporterText); Assert.AreEqual(1, Regex.Matches(reporterText, "up").Count, "Reporter text:" + reporterText); Assert.IsTrue(reporterText.Contains("move"), "Reporter text:" + reporterText); }
public void DragAndDropToElement() { driver.Url = dragAndDropPage; IWebElement img1 = driver.FindElement(By.Id("test1")); IWebElement img2 = driver.FindElement(By.Id("test2")); Actions actionProvider = new Actions(driver); actionProvider.DragAndDrop(img2, img1).Perform(); Assert.AreEqual(img1.Location, img2.Location); }
/// <summary> /// Handles the command. /// </summary> /// <param name="driver">The driver used to execute the command.</param> /// <param name="locator">The first parameter to the command.</param> /// <param name="value">The second parameter to the command.</param> /// <returns>The result of the command.</returns> protected override object HandleSeleneseCommand(IWebDriver driver, string locator, string value) { IWebElement dragElement = this.finder.FindElement(driver, locator); IWebElement dropElement = this.finder.FindElement(driver, value); Actions actionBuilder = new Actions(driver); actionBuilder.DragAndDrop(dragElement, dropElement).Perform(); return null; }
public void DragAndDropToElement() { driver.Url = dragAndDropPage; IWebElement img1 = driver.FindElement(By.Id("test1")); IWebElement img2 = driver.FindElement(By.Id("test2")); Actions actionProvider = new Actions(driver); actionProvider.DragAndDrop(img2, img1).Perform(); Assert.AreEqual(img1.Location, img2.Location); }
public void DranNDrop() { NavigationHelper.NavigateToUrl("http://demos.telerik.com/kendo-ui/dragdrop/events"); Actions act = new Actions(ObjectRepository.Driver); IWebElement src = ObjectRepository.Driver.FindElement(By.Id("draggable")); IWebElement tar = ObjectRepository.Driver.FindElement(By.Id("droptarget")); act.DragAndDrop(src, tar) .Build() .Perform(); Thread.Sleep(4000); }
public void TestDragDrop() { IWebDriver driver = new ChromeDriver(@"C:\ChromeDriver\"); driver.Navigate().GoToUrl("http://dl.dropbox.com/u/55228056/DragDropDemo.html"); IWebElement source = driver.FindElement(By.Id("draggable")); IWebElement target = driver.FindElement(By.Id("droppable")); Actions builder = new Actions(driver); builder.DragAndDrop(source, target).Perform(); Assert.AreEqual("Dropped!", target.Text); driver.Close(); }
public static bool PerformDragAndDrop(SearchBy sourceBy, string sourceLocator, SearchBy targetBy, string targetLocator) { IWebElement source = FindElement(sourceBy, sourceLocator, 10); IWebElement target = FindElement(targetBy, targetLocator, 10); OpenQA.Selenium.Interactions.Actions builder = new OpenQA.Selenium.Interactions.Actions(_driver); try { loggerInfo.Instance.Message("Perform Drag and Drop for : " + "Source:{" + sourceLocator + "} Destination:{" + targetLocator + "}"); builder.DragAndDrop(source, target).Build().Perform(); } catch (Exception e) { Exception exception = new Exception(e.Message); loggerInfo.Instance.LogAppErro(exception, "Source:{" + sourceLocator + "} Destination:{" + targetLocator + "}", LogLevel.Error); return(false); } return(true); }
public IMouseActions DragAndDrop(BaseElement source, BaseElement target) { actions.DragAndDrop(source.IWebElement, target.IWebElement); return(this); }
/// <summary> /// drag and drops from the initial to the end locator /// </summary> /// <param name="initialLocator">where to click and hold</param> /// <param name="endLocator">where to release the mouse click</param> public void DragAndDrop(string initialLocator, string endLocator) { Actions action = new Actions(driver); WaitForDisplayAndClick(initialLocator, LocateBy.XPath); IWebElement start = WaitForElementPresent(By.XPath(initialLocator)); IWebElement end = WaitForElementPresent(By.XPath(endLocator)); action.DragAndDrop(start, end).Build().Perform(); WaitForAJAXRequest(); }
/// <summary> /// Method to drag the source object on the target object. /// </summary> /// <param name="targetObjDic">Dictionary : Target object details</param> public void DragAndDrop(Dictionary<string, string> targetObjDic) { IWebElement sourceObject = WaitAndGetElement(); // Set second object's information in dictionary SetObjDataRow(targetObjDic); IWebElement targetObject = WaitAndGetElement(); Actions action = new Actions(Driver); action.DragAndDrop(sourceObject, targetObject).Perform(); Thread.Sleep(100); }
public void MoveModuleUsingDragAndDrop(string moduleNumber, string newLocation) { Trace.WriteLine(BasePage.TraceLevelComposite + "Move a Module, using Drag and Drop:"); Actions action = new Actions(_driver); action.DragAndDrop(FindElement(By.XPath("//div[a[@name = '" + moduleNumber + "']]/div")), FindElement(By.XPath(newLocation))).Build().Perform(); Thread.Sleep(1000); }
/// <summary> /// Drag one element to another /// </summary> /// <param name="source">What to drag</param> /// <param name="target">Where to drag to</param> public void DragAndDropElement(IWebElement source, IWebElement target) { Actions action = new Actions(Driver); action.DragAndDrop(source, target).Perform(); }
public void AddNewModuleUsingDragAndDrop(string moduleName, string location) { Trace.WriteLine(BasePage.TraceLevelComposite + "Add a Module, Using Drag&Drop:"); WaitForElement(By.XPath(moduleName)).ScrollIntoView().WaitTillVisible().Click(); Trace.WriteLine(TraceLevelPage + "Mouse over module: '" + moduleName); Actions action = new Actions(_driver); //IWebElement dragArea = FindElement(By.XPath(moduleName)); //IWebElement to = FindElement(By.XPath(Modules.LocationDescription[location].IdWhenOnPage)); action.MoveToElement(FindElement(By.XPath(moduleName))).Perform(); action.DragAndDrop(FindElement(By.XPath(moduleName)), FindElement(By.XPath(Modules.LocationDescription[location].IdWhenOnPage)).ScrollIntoView()); //action.ClickAndHold(dragArea).MoveToElement(to.ScrollIntoView()).Release(); action.Build().Perform(); Thread.Sleep(1000); }
public void MovePage(string pageName, string newLocation, PageType pageType) { Trace.WriteLine(BasePage.TraceLevelComposite + "Move the Page"); OpenPageList(pageType, pageName); Actions action = new Actions(_driver); action.DragAndDrop(FindElement(By.XPath("//div[contains(@id, 'Tabs_ctlPages')]//span[text() = '" + pageName + " ']")), FindElement(By.XPath("//div[contains(@id, 'Tabs_ctlPages')]//span[text() = '" + newLocation + " ']"))). Build(). Perform(); WaitForElement(By.XPath(OperationConfirmationMessage), 30); }
private void SeleniumDragAndDrop(string dragElementKey, string dropElementKey, IWebElement locatorFrom, IWebElement locatorTo) { if (locatorFrom == null) assert.Fail("\"" + dragElementKey + "\" is not avilable to drag."); if (locatorTo == null) assert.Fail("\"" + dropElementKey + "\" is not avilable to drop \"" + dropElementKey + "\"."); var driver = (IWebDriver) GetBrowser; var action = new Actions(driver); action.DragAndDrop(locatorFrom, locatorTo).Perform(); }
/* public void drawSign() { Actions builder = new Actions(GetWebDriver()); Action drawAction = builder.MoveToElement(//*[@id='clicknew']", 50, 100) //signatureWebElement is the element that holds the signature element you have in the DOM .ClickAndHold() .moveByOffset(100, 50) .moveByOffset(6, 7) .release() .build(); drawAction.Perform(); } */ public void DragAndDrop(string element,string target) { WaitForElementPresent(element, 20); Assert.IsTrue(IsElementPresent(element)); WaitForElementPresent(target, 20); Assert.IsTrue(IsElementPresent(target)); var el = GetWebDriver().FindElement(ByLocator(element)); var tar = GetWebDriver().FindElement(ByLocator(target)); var builder = new Actions(GetWebDriver()); //maybe take out .Build builder.DragAndDrop(el,tar).Build().Perform(); }
public void AddNewModuleUsingDragAndDrop(string moduleName, string moduleNameOnPage, string location) { Trace.WriteLine(BasePage.TraceLevelComposite + "Add a Module, Using Drag&Drop:"); WaitForElement(By.XPath(moduleName)).ScrollIntoView().WaitTillVisible().Click(); Trace.WriteLine(TraceLevelPage + "Mouse over module: '" + moduleName); Actions action = new Actions(_driver); action.MoveToElement(FindElement(By.XPath(moduleName))).Perform(); action.DragAndDrop(FindElement(By.XPath(moduleName)), FindElement(By.XPath(location)).ScrollIntoView()); action.Build().Perform(); /*IWebElement dragElement=FindElement(By.XPath(moduleName)); IWebElement dropElement=FindElement(By.XPath(location)); Actions builder = new Actions(_driver); builder.ClickAndHold(dragElement) .MoveToElement(dropElement) .Release(dropElement); builder.Build().Perform();*/ Thread.Sleep(1000); }
public void MovePage(string pageName, string newLocation, string pageType) { OpenPageList(pageType, pageName); Actions action = new Actions(_driver); action.DragAndDrop(FindElement(By.XPath("//div[contains(@id, 'Tabs_ctlPages')]//span[text() = '" + pageName + " ']")), FindElement(By.XPath("//div[contains(@id, 'Tabs_ctlPages')]//span[text() = '" + newLocation + " ']"))). Build(). Perform(); WaitForElement(By.XPath(OperationConfirmationMessage)); }
/// <summary> /// Mousedown event on the element then drag to location. /// </summary> /// <param name="element"></param> public static void DragAndDrop(this IWebElement source, IWebElement destination) { Actions act = new Actions(Browser.Driver); act.DragAndDrop(source, destination).Perform(); }