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


C# Actions.Release方法代码示例

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


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

示例1: MaxZoom

        //an boundary constraint (to prevent the user from observing the future and the past(e.g. before 13.7Ga BC) )
        public void MaxZoom(double lt, double rt, int zoom)
        {
            IWebElement buttonZoomOut = Driver.FindElement(By.Id("buttonZoomOut"));
            Actions actions = new Actions(Driver);

            (Driver as IJavaScriptExecutor).ExecuteScript("$(\"#axis\").axis(\"setRange\"," + lt + "," + rt + ");");

            actions.Build();
            actions.MoveToElement(buttonZoomOut, 0, 0);
            for (int k = 0; k < zoom; k++)
            {
                actions.Click();
            }
            actions.Release();
            actions.Perform();

            var afterZoom = (Driver as IJavaScriptExecutor).
            ExecuteScript("return $(\"#axis\").axis(\"getRange\");");

            var afterzooml = Convert.ToDouble((afterZoom as Dictionary<string, object>)["left"]);
            var afterzoomr = Convert.ToDouble((afterZoom as Dictionary<string, object>)["right"]);

            Assert.IsTrue(afterzooml >= -13700000000.0);
            Assert.IsTrue(afterzoomr <= 0.0);
        }
开发者ID:Bzdun,项目名称:NewProject,代码行数:26,代码来源:AxisZoomTestIntestAxisPage.cs

示例2: ClickLong

        /// <summary>
        /// Click and hold an element
        /// </summary>
        /// <param name="element">Page element</param>
        /// <param name="ms">Number of milliseconds to hold down the click</param>
        public static void ClickLong(this IBrowser browser, PageElement element, int ms)
        {
            var action = new Actions(browser.IWebDriver);

            action.ClickAndHold(browser.Find(element)).Build().Perform();
            Thread.Sleep(ms);
            action.Release(browser.Find(element)).Build().Perform();
        }
开发者ID:avinodkumar,项目名称:Selenium-Chloride,代码行数:13,代码来源:BrowserClickExtensions.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: ShouldAllowDragAndDrop

        public void ShouldAllowDragAndDrop()
        {
            driver.Url = droppableItems;

            DateTime waitEndTime = DateTime.Now.Add(TimeSpan.FromSeconds(15));

            while (!IsElementAvailable(driver, By.Id("draggable")) && (DateTime.Now < waitEndTime))
            {
                System.Threading.Thread.Sleep(200);
            }

            if (!IsElementAvailable(driver, By.Id("draggable")))
            {
                throw new Exception("Could not find draggable element after 15 seconds.");
            }

            IWebElement toDrag = driver.FindElement(By.Id("draggable"));
            IWebElement dropInto = driver.FindElement(By.Id("droppable"));

            Actions actionProvider = new Actions(driver);

            IAction holdDrag = actionProvider.ClickAndHold(toDrag).Build();

            IAction move = actionProvider.MoveToElement(dropInto).Build();

            IAction drop = actionProvider.Release(dropInto).Build();

            holdDrag.Perform();
            move.Perform();
            drop.Perform();

            dropInto = driver.FindElement(By.Id("droppable"));
            string text = dropInto.FindElement(By.TagName("p")).Text;

            Assert.AreEqual("Dropped!", text);
        }
开发者ID:RanchoLi,项目名称:selenium,代码行数:36,代码来源:BasicMouseInterfaceTest.cs

示例5: PerformDragAndDropWithMouse

        private void PerformDragAndDropWithMouse()
        {
            driver.Url = draggableLists;

            IWebElement dragReporter = driver.FindElement(By.Id("dragging_reports"));

            IWebElement toDrag = driver.FindElement(By.Id("rightitem-3"));
            IWebElement dragInto = driver.FindElement(By.Id("sortable1"));

            Actions actionProvider = new Actions(driver);
            IAction holdItem = actionProvider.ClickAndHold(toDrag).Build();

            IAction moveToSpecificItem = actionProvider.MoveToElement(driver.FindElement(By.Id("leftitem-4"))).Build();

            IAction moveToOtherList = actionProvider.MoveToElement(dragInto).Build();

            IAction drop = actionProvider.Release(dragInto).Build();

            Assert.AreEqual("Nothing happened.", dragReporter.Text);

            holdItem.Perform();
            moveToSpecificItem.Perform();
            moveToOtherList.Perform();

            Assert.AreEqual("Nothing happened. DragOut", dragReporter.Text);
            drop.Perform();
        }
开发者ID:hugs,项目名称:Selenium2,代码行数:27,代码来源:BasicMouseInterfaceTest.cs

示例6: TestGestures_SeleniumMouseMoveError

        // Mark this test with TestMethod attribute, if need to check error
        // of mouse move actions in Selenium.
        public void TestGestures_SeleniumMouseMoveError()
        {
            Dictionary<string, object> offset;

            const int startX = 100;
            const int startY = 100;

            Actions action = new Actions(Driver);
            action.MoveToElement(vcPageObj.VirtualCanvas, startX, startY).Perform();

            for (int i = 0; i < 101; i++)
            {
                GoToUrl();

                action.Build();
                action.ClickAndHold();
                action.MoveByOffset(i, i);
                action.Release();
                action.MoveByOffset(-i, -i);
                action.Perform();

                offset = ExecuteScriptGetJson("return offset;");
                Console.WriteLine("Expected offset ({0}, {1}); Observed offset: ({2}, {3});", i, i, offset["xOffset"], offset["yOffset"]);
            }
        }
开发者ID:Bzdun,项目名称:NewProject,代码行数:27,代码来源:GesturesTests.cs

示例7: MinZoomDay

        ////inner zoom not deeper 1 day
        public void MinZoomDay(int sYear, int sMonth, int sDay, int eYear, int eMonth, int eDay, double l, int zoom)
        {
            IWebElement buttonZoomIn = Driver.FindElement(By.Id("buttonZoomIn"));
            Actions actions = new Actions(Driver);

            var d = (Driver as IJavaScriptExecutor).ExecuteScript
                        ("return $(\"#axis\").axis(\"getYearsBetweenDates\"," +
                        sYear + "," + sMonth + "," + sDay + "," + eYear + "," + eMonth + "," + eDay + ");");

            (Driver as IJavaScriptExecutor).ExecuteScript("$(\"#axis\").axis(\"setPresent\"," + sYear + "," + sMonth + "," + sDay + ");");

            double betwenDays = Convert.ToDouble(d);
            double r = betwenDays + l;
            (Driver as IJavaScriptExecutor).ExecuteScript("$(\"#axis\").axis(\"setRange\"," + l + "," + r + ");");

            actions.Build();
            actions.MoveToElement(buttonZoomIn, 0, 0);
            for (int k = 0; k < zoom; k++)
            {
                actions.Click();
            }
            actions.Release();
            actions.Perform();

            var afterZoom = (Driver as IJavaScriptExecutor).
            ExecuteScript("return $(\"#axis\").axis(\"getRange\");");
            var azl = Convert.ToDouble((afterZoom as Dictionary<string, object>)["left"]);
            var azr = Convert.ToDouble((afterZoom as Dictionary<string, object>)["right"]);
            double z = azr - azl;

            double d1 = OneDay(1233, 3, 4, 5);
            double d2 = OneDay(23, 8, 17, 18);
            double d3 = OneDay(2005, 11, 1, 2);
            Assert.IsTrue(z >= d1);
            Assert.IsTrue(z >= d2);
            Assert.IsTrue(z >= d3);
        }
开发者ID:Bzdun,项目名称:NewProject,代码行数:38,代码来源:AxisZoomTestIntestAxisPage.cs

示例8: ZoomOut

        // zoom out
        public void ZoomOut(double l, double r)
        {
            IWebElement buttonZoomOut = Driver.FindElement(By.Id("buttonZoomOut"));
            Actions actions = new Actions(Driver);

            (Driver as IJavaScriptExecutor).ExecuteScript("$(\"#axis\").axis(\"setRange\"," + l + "," + r + ");");
            var beforeZoomOut = (Driver as IJavaScriptExecutor).
            ExecuteScript("return $(\"#axis\").axis(\"getRange\");");
            var bzl = Convert.ToDouble((beforeZoomOut as Dictionary<string, object>)["left"]);
            var bzr = Convert.ToDouble((beforeZoomOut as Dictionary<string, object>)["right"]);
            double z1 = bzr - bzl;

            actions.Build();
            actions.MoveToElement(buttonZoomOut, 0, 0);
            actions.Click();
            actions.Release();
            actions.Perform();

            var afterZoomOut = (Driver as IJavaScriptExecutor).
            ExecuteScript("return $(\"#axis\").axis(\"getRange\");");
            var azl = Convert.ToDouble((afterZoomOut as Dictionary<string, object>)["left"]);
            var azr = Convert.ToDouble((afterZoomOut as Dictionary<string, object>)["right"]);
            double z2 = azr - azl;

            if (z1 <= OneDay(134, 5, 2, 4))
            {
                Assert.IsTrue(z1 <= z2);
            }
            else
            {
                Assert.IsTrue(z1 < z2);
            }
        }
开发者ID:Bzdun,项目名称:NewProject,代码行数:34,代码来源:AxisZoomTestIntestAxisPage.cs

示例9: TestZoomOutMarker

        public void TestZoomOutMarker()
        {
            GoToUrl();

            IWebElement buttonHelper = Driver.FindElement(By.Id("buttonHelper"));
            IWebElement buttonZoomMarkerOut = Driver.FindElement(By.Id("buttonZoomMarkerOut"));
            Actions actions = new Actions(Driver);

            actions.Build();
            actions.MoveToElement(buttonHelper, 0, 0);
            actions.Click();

            var afterHelper = (Driver as IJavaScriptExecutor).
            ExecuteScript("return $(\"#axis\").axis(\"getRange\");");
            var ahl = Convert.ToDouble((afterHelper as Dictionary<string, object>)["left"]);
            var ahr = Convert.ToDouble((afterHelper as Dictionary<string, object>)["right"]);
            double z1 = ahr - ahl;

            actions.MoveToElement(buttonZoomMarkerOut, 0, 0);
            actions.Click();
            actions.Release();
            actions.Perform();

            var afterZoomOutMarker = (Driver as IJavaScriptExecutor).
            ExecuteScript("return $(\"#axis\").axis(\"getRange\");");
            var azml = Convert.ToDouble((afterZoomOutMarker as Dictionary<string, object>)["left"]);
            var azmr = Convert.ToDouble((afterZoomOutMarker as Dictionary<string, object>)["right"]);
            double z2 = azmr - azml;

            Assert.IsTrue(ahl > azml && ahr < azmr && z1 < z2);
        }
开发者ID:Bzdun,项目名称:NewProject,代码行数:31,代码来源:AxisZoomTestIntestAxisPage.cs

示例10: MinZoomNoMoreFourSigns

        //inner zoom not deeper 4 decimal fraction digits
        public void MinZoomNoMoreFourSigns(double x1, double x2, int zoom)
        {
            IWebElement buttonZoomIn = Driver.FindElement(By.Id("buttonZoomIn"));
            Actions actions = new Actions(Driver);

            (Driver as IJavaScriptExecutor).ExecuteScript("$(\"#axis\").axis(\"setRange\"," + x1 + "," + x2 + ");");

            actions.Build();
            actions.MoveToElement(buttonZoomIn, 0, 0);
            for (int k = 0; k < zoom; k++)
            {
                actions.Click();
            }
            actions.Release();
            actions.Perform();

            var afterZoom = (Driver as IJavaScriptExecutor).
            ExecuteScript("return $(\"#axis\").axis(\"getRange\");");

            var afterzooml = Convert.ToDouble((afterZoom as Dictionary<string, object>)["left"]);
            var afterzoomr = Convert.ToDouble((afterZoom as Dictionary<string, object>)["right"]);
            double aftern = afterzoomr - afterzooml;

            int decimaldigitsl = Counter(afterzooml);
            int decimaldigitsr = Counter(afterzoomr);
            int decimaldigitsn = Counter(aftern);

            Assert.IsTrue(decimaldigitsl <= 4 && decimaldigitsr <= 4);
            Assert.IsTrue(decimaldigitsn <= 4);
        }
开发者ID:Bzdun,项目名称:NewProject,代码行数:31,代码来源:AxisZoomTestIntestAxisPage.cs

示例11: Release

 /// <summary>
 /// Releases the element from a ClickAndHold.
 /// </summary>
 /// <param name="element"></param>
 public static void Release(this IWebElement element)
 {
     Actions act = new Actions(Browser.Driver);
     act.Release(element).Perform();
 }
开发者ID:dnamartin,项目名称:Automation,代码行数:9,代码来源:Extensions.cs

示例12: TestMouse_MoveAndClick_Rectangle

        public void TestMouse_MoveAndClick_Rectangle()
        {
            GoToUrl();

            IWebElement vc = Driver.FindElement(By.Id("vc"));
            IWebElement button = Driver.FindElement(By.Id("button"));

            var rectCenterX = Convert.ToDouble((Driver as IJavaScriptExecutor).ExecuteScript("return rectCenterX;"));
            var scale = Convert.ToDouble((Driver as IJavaScriptExecutor).ExecuteScript("return scale;"));

            Actions actions = new Actions(Driver);
            // building mouse moves on the virtual canvas element
            actions.Build();
            actions.MoveToElement(vc, vc.Size.Width / 2 + (int)(rectCenterX / scale), vc.Size.Height / 2);
            actions.Click();
            actions.MoveToElement(button, 0, 0);
            actions.Release();
            actions.Perform();

            var res = (Driver as IJavaScriptExecutor).ExecuteScript("return isRectMovedIn;");
            Assert.AreNotEqual(0.0, Convert.ToDouble(res));
            res = (Driver as IJavaScriptExecutor).ExecuteScript("return isRectMovedOut;");
            Assert.AreNotEqual(0.0, Convert.ToDouble(res));
            res = (Driver as IJavaScriptExecutor).ExecuteScript("return isRectClicked;");
            Assert.AreNotEqual(0.0, Convert.ToDouble(res));
        }
开发者ID:Bzdun,项目名称:NewProject,代码行数:26,代码来源:VirtualCanvasTests.cs


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