当前位置: 首页>>代码示例>>C#>>正文


C# Actions.DragAndDrop方法代码示例

本文整理汇总了C#中OpenQA.Selenium.Interactions.Actions.DragAndDrop方法的典型用法代码示例。如果您正苦于以下问题:C# Actions.DragAndDrop方法的具体用法?C# Actions.DragAndDrop怎么用?C# Actions.DragAndDrop使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在OpenQA.Selenium.Interactions.Actions的用法示例。


在下文中一共展示了Actions.DragAndDrop方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DragAndDropOnJQueryItems

        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);
        }
开发者ID:krosenvold,项目名称:selenium-git-release-candidate,代码行数:34,代码来源:DragAndDropTest.cs

示例2: DragAndDropToElement

 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);
 }
开发者ID:draculavlad,项目名称:selenium,代码行数:9,代码来源:DragAndDropTest.cs

示例3: HandleSeleneseCommand

        /// <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;
        }
开发者ID:RanchoLi,项目名称:selenium,代码行数:16,代码来源:DragAndDropToObject.cs

示例4: DranNDrop

        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);
        }
开发者ID:Saltorel,项目名称:BDD-CSharp,代码行数:13,代码来源:TestMouseAction.cs

示例5: TestDragDrop

        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();
        }
开发者ID:vikramuk,项目名称:Selenium,代码行数:14,代码来源:DragDropTest.cs

示例6: MovePage

		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));
		}
开发者ID:rrsc,项目名称:Dnn.Platform,代码行数:12,代码来源:AdminPageManagementPage.cs

示例7: SeleniumDragAndDrop

 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();
 }
开发者ID:HansinieJ,项目名称:CodeSpec,代码行数:9,代码来源:SeleniumUiAutomationService.cs

示例8: DragAndDrop

        /// <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);
        }
开发者ID:Thinksys,项目名称:krypton,代码行数:16,代码来源:TestObject.cs

示例9: DragAndDropElement

 /// <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();
 }
开发者ID:koreyba,项目名称:lottosend,代码行数:10,代码来源:DriverCover.cs

示例10: MoveModuleUsingDragAndDrop

		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);
		}
开发者ID:kp-xcess,项目名称:Dnn.Platform,代码行数:10,代码来源:Modules.cs

示例11: AddNewModuleUsingDragAndDrop

		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);
		}
开发者ID:kp-xcess,项目名称:Dnn.Platform,代码行数:20,代码来源:Modules.cs

示例12: Actions

        /*    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();
        }
开发者ID:Madhava999,项目名称:New-skin,代码行数:26,代码来源:DriverHelper.cs

示例13: AddNewModuleUsingDragAndDrop

		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);
		}
开发者ID:rrsc,项目名称:Dnn.Platform,代码行数:26,代码来源:Modules.cs

示例14: MovePage

		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);
		}
开发者ID:uXchange,项目名称:Dnn.Platform,代码行数:14,代码来源:AdminPageManagementPage.cs

示例15: DragAndDrop

 /// <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();
 }
开发者ID:aliaksandr-trush,项目名称:csharp-automaton,代码行数:14,代码来源:UIUtil.cs


注:本文中的OpenQA.Selenium.Interactions.Actions.DragAndDrop方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。