當前位置: 首頁>>代碼示例>>C#>>正文


C# Actions.DragAndDropToOffset方法代碼示例

本文整理匯總了C#中OpenQA.Selenium.Interactions.Actions.DragAndDropToOffset方法的典型用法代碼示例。如果您正苦於以下問題:C# Actions.DragAndDropToOffset方法的具體用法?C# Actions.DragAndDropToOffset怎麽用?C# Actions.DragAndDropToOffset使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在OpenQA.Selenium.Interactions.Actions的用法示例。


在下文中一共展示了Actions.DragAndDropToOffset方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: Test

        public void Test()
        {
            driver = new FirefoxDriver();
            driver.Navigate().GoToUrl("http://www.jpcenter.ru");
            driver.FindElement(By.PartialLinkText(make)).Click();
            driver.FindElement(By.PartialLinkText(model)).Click();
            // Wait for element
            driver.Manage().Timeouts().ImplicitlyWait(new TimeSpan(0, 0, 45));

            // Grab the element and then feed it to the actions statement below.
            IWebElement element = driver.FindElement(By.XPath("//div[@id='aj_sl1']/div[2]/img"));
            IWebElement element2 = driver.FindElement(By.Id("aj_sl1"));

            Actions actionsProvider = new Actions(driver);
            actionsProvider.DragAndDropToOffset(element, -100, -100);
            actionsProvider.DragAndDropToOffset(element2, -100, -100);
        }
開發者ID:CaptainClaypole,項目名稱:seleniumscrapevehicles,代碼行數:17,代碼來源:Class1.cs

示例2: 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)
        {
            string[] parts = value.Split(new string[] { "," }, 2, StringSplitOptions.None);
            int deltaX = int.Parse(parts[0], CultureInfo.InvariantCulture);
            int deltaY = int.Parse(parts[1], CultureInfo.InvariantCulture);

            IWebElement element = this.finder.FindElement(driver, locator);
            Actions actionBuilder = new Actions(driver);
            actionBuilder.DragAndDropToOffset(element, deltaX, deltaY).Perform();

            return null;
        }
開發者ID:Rameshnathan,項目名稱:selenium,代碼行數:19,代碼來源:DragAndDrop.cs

示例3: DragSlider

        public void DragSlider()
        {
            // Wait for element
            driver.Manage().Timeouts().ImplicitlyWait(new TimeSpan(0, 0, 45));

            // Grab the element and then feed it to the actions statement below.
            IWebElement element = driver.FindElement(By.XPath("//div[@id='aj_sl1']/div[2]/img"));

            Console.WriteLine(element.ToString());
            Console.ReadLine();

            Actions actionsProvider = new Actions(driver);
            actionsProvider.DragAndDropToOffset(element, 50, 0);

            actionsProvider.ClickAndHold(element);
            actionsProvider.MoveByOffset(50, 0);
            actionsProvider.Release(element);
        }
開發者ID:CaptainClaypole,項目名稱:seleniumscrapevehicles,代碼行數:18,代碼來源:Class1.cs

示例4: MouseActiveLeft

        public void MouseActiveLeft(double left, double right, int shift)
        {
            Actions action = new Actions(Driver);

            IWebElement axi = Driver.FindElement(By.Id("axis"));
            (Driver as IJavaScriptExecutor).ExecuteScript("$(\"#axis\").axis(\"setRange\"," + left + "," + right + ");");
            var before = (Driver as IJavaScriptExecutor).ExecuteScript("return $(\"#axis\").axis(\"getRange\");");
            var bL = Convert.ToDouble((before as Dictionary<string, object>)["left"]);
            var bR = Convert.ToDouble((before as Dictionary<string, object>)["right"]);

            action.Build();
            action.DragAndDropToOffset(axi, -shift, 0);
            action.Perform();

            var after = (Driver as IJavaScriptExecutor).ExecuteScript("return $(\"#axis\").axis(\"getRange\");");
            var aL = Convert.ToDouble((after as Dictionary<string, object>)["left"]);
            var aR = Convert.ToDouble((after as Dictionary<string, object>)["right"]);
            Assert.IsTrue(aL > bL && aR > bR);
        }
開發者ID:sadeghsm,項目名稱:ChronoZoom,代碼行數:19,代碼來源:AxisPanAndZoomTest.cs

示例5: DragTooFar

        public void DragTooFar()
        {
            driver.Url = dragAndDropPage;
            IWebElement img = driver.FindElement(By.Id("test1"));

            // Dragging too far left and up does not move the element. It will be at 
            // its original location after the drag.
            Point originalLocation = new Point(0, 0);
            Actions actionProvider = new Actions(driver);
            actionProvider.DragAndDropToOffset(img, int.MinValue, int.MinValue).Perform();
            Point newLocation = img.Location;
            Assert.LessOrEqual(newLocation.X, 0);
            Assert.LessOrEqual(newLocation.Y, 0);

            // TODO(jimevans): re-enable this test once moveto does not exceed the
            // coordinates accepted by the browsers (Firefox in particular). At the
            // moment, even though the maximal coordinates are limited, mouseUp 
            // fails because it cannot get the element at the given coordinates.
            //actionProvider.DragAndDropToOffset(img, int.MaxValue, int.MaxValue).Perform();
            //We don't know where the img is dragged to , but we know it's not too
            //far, otherwise this function will not return for a long long time
        }
開發者ID:kaushik9k,項目名稱:Selenium2,代碼行數:22,代碼來源:DragAndDropTest.cs

示例6: drag

        private Point drag(IWebElement elem, Point initialLocation, int moveRightBy, int moveDownBy)
        {
            Point expectedLocation = new Point(initialLocation.X, initialLocation.Y);
            expectedLocation.Offset(moveRightBy, moveDownBy);

            Actions actionProvider = new Actions(driver);
            actionProvider.DragAndDropToOffset(elem, moveRightBy, moveDownBy).Perform();

            return expectedLocation;
        }
開發者ID:draculavlad,項目名稱:selenium,代碼行數:10,代碼來源:DragAndDropTest.cs

示例7: DragTooFar

        public void DragTooFar()
        {
            driver.Url = dragAndDropPage;
            IWebElement img = driver.FindElement(By.Id("test1"));

            // Dragging too far left and up does not move the element. It will be at
            // its original location after the drag.
            Point originalLocation = new Point(0, 0);
            Actions actionProvider = new Actions(driver);
            actionProvider.DragAndDropToOffset(img, int.MinValue, int.MinValue).Perform();
            Assert.AreEqual(originalLocation, img.Location);

            actionProvider.DragAndDropToOffset(img, int.MaxValue, int.MaxValue).Perform();
            //We don't know where the img is dragged to , but we know it's not too
            //far, otherwise this function will not return for a long long time
        }
開發者ID:asynchrony,項目名稱:Selenium2,代碼行數:16,代碼來源:DragAndDropTest.cs

示例8: DragToOffset

 public static IWebElement DragToOffset(this IWebElement element, int x, int y)
 {
     var action = new Actions(WebDriverTestBase.driver);
     action.DragAndDropToOffset(element, x, y).Build().Perform();
     return element;
 }
開發者ID:sakthijas,項目名稱:ProtoTest.Golem,代碼行數:6,代碼來源:WebDriverExtensions.cs

示例9: DragAndDropOffset

 /// <summary>
 /// Mousedown event on the element then drag to offset.
 /// </summary>
 /// <param name="element"></param>
 public static void DragAndDropOffset(this IWebElement element, int x, int y)
 {
     Actions act = new Actions(Browser.Driver);
     act.DragAndDropToOffset(element, x, y).Perform();
 }
開發者ID:dnamartin,項目名稱:Automation,代碼行數:9,代碼來源:Extensions.cs


注:本文中的OpenQA.Selenium.Interactions.Actions.DragAndDropToOffset方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。