當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。