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


C# Actions.Build方法代码示例

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


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

示例3: SetDefault

        /// <summary>
        /// This method set the context of OpenQA.Selenium.Interactions.Actions field to default.
        /// </summary>
        public void SetDefault()
        {
            Actions reverseBuilder = new Actions(driver);

            while (log.Count != 0)
            {
                Point offset = log.Pop();
                reverseBuilder.MoveByOffset(offset.X, offset.Y);
            }

            IAction action = reverseBuilder.Build();
            action.Perform();

            log.Clear();
        }
开发者ID:Bzdun,项目名称:NewProject,代码行数:18,代码来源:ActionsExtension.cs

示例4: 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

示例5: 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

示例6: 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

示例7: 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

示例8: MouseOver

 /// <summary>
 ///     MouseOver a sequence of By objects in order.
 /// </summary>
 /// <param name="bys">A variadic list of By objects to mouse over.</param>
 /// <returns>The browser instance.</returns>
 public Browser MouseOver(params By[] bys)
 {
     var actions = new Actions(WebDriver);
     bys.Select(by => WebDriver.FindElement(by)).ToList()
         .ForEach(elem => actions.MoveToElement(elem));
     actions.Build().Perform();
     return this;
 }
开发者ID:Madhava999,项目名称:New-skin,代码行数:13,代码来源:Browser.cs

示例9: 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

示例10: PressKey

        public static void PressKey(string key)
        {
            var builder = new Actions(SeleniumDriver.Instance);

            switch (key.ToLower())
            {
                case "return":
                    builder.SendKeys(Keys.Return);
                    break;
                case "tab":
                    builder.SendKeys(Keys.Tab);
                    break;
                case "arrowdown":
                    builder.SendKeys(Keys.ArrowDown);
                    break;
                case "arrowup":
                    builder.SendKeys(Keys.ArrowUp);
                    break;
                case "arrowleft":
                    builder.SendKeys(Keys.ArrowLeft);
                    break;
                case "arrowright":
                    builder.SendKeys(Keys.ArrowRight);
                    break;
                case "home":
                    builder.SendKeys(Keys.Home);
                    break;
                case "end":
                    builder.SendKeys(Keys.End);
                    break;
                case "pageup":
                    builder.SendKeys(Keys.PageUp);
                    break;
                case "pagedown":
                    builder.SendKeys(Keys.PageDown);
                    break;
            }


            builder.Build().Perform();
        }
开发者ID:rohanbaraskar,项目名称:SeleniumAutomationFramework,代码行数:41,代码来源:SeleniumHelper.cs

示例11: CtrlClick_Should_Open_Link_In_Other_Window

		public void CtrlClick_Should_Open_Link_In_Other_Window()
		{
			var b = GetMockedBrowser();
			var dr = new SimpleBrowserDriver((IBrowser)b);
			dr.Navigate().GoToUrl("http://www.a.com/link.htm");
			Assert.That(dr.WindowHandles.Count == 1);
			Assert.That(dr.Url == "http://www.a.com/link.htm");

			var link = dr.FindElement(By.LinkText("link"));
			Assert.NotNull(link);
			link.Click();
			Assert.That(dr.Url == "http://www.a.com/otherpage.htm");
			dr.Navigate().Back();
			Assert.That(dr.Url == "http://www.a.com/link.htm");
			link = dr.FindElement(By.LinkText("link"));

			Actions builder = new Actions(dr);
			builder.KeyDown(Keys.Control).Click(link).KeyUp(Keys.Control);
			var act = builder.Build();
			act.Perform();

			Assert.That(dr.Url == "http://www.a.com/link.htm");
			Assert.That(dr.WindowHandles.Count == 2);

		}
开发者ID:wip-alex,项目名称:SimpleBrowser.WebDriver,代码行数:25,代码来源:SimpleNavigateTests.cs

示例12: 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

示例13: Click

        /// <summary>
        /// Method to click on button and Link
        ///
        /// </summary>
        public void Click(Dictionary<int, string> keyWordDic = null, string data = null)
        {
            try
            {
                _testObject = WaitAndGetElement();
                DateTime startTime = DateTime.Now;
                if (Utility.GetParameter("runbyevents").Equals("true"))
                {
                    switch (Browser.BrowserName.ToLower())
                    {
                        case "ie":
                        case "iexplore":
                            ExecuteScript(_testObject, "arguments[0].click();");
                            try
                            {
                                WaitForObjectNotPresent(Utility.GetVariable("ObjectTimeout"),
                                                             Utility.GetVariable("GlobalTimeout"), keyWordDic);
                            }
                            catch
                            {
                                //Nothing to throw in this case
                            }
                            break;
                        default:
                            _testObject.Click();
                            break;
                    }
                }
                else
                {
                    try
                    {
                        // Perform Shift+Click only if Shift key is passed as Data for action sheet data in case Chrome.
                        if ("Shift".Equals(data, StringComparison.OrdinalIgnoreCase) && Browser.BrowserName.Equals(KryptonConstants.BROWSER_CHROME, StringComparison.OrdinalIgnoreCase))
                        {
                            Actions objAction = new Actions(Driver);

                            objAction = objAction.KeyDown(Keys.Shift).Click(_testObject).KeyUp(Keys.Shift);
                            objAction.Build();
                            objAction.Perform();
                        }
                        else
                        {
                            _testObject.Click();
                        }

                        // Pause here for .5 sec as on mac safari VerifyTextOnPage after this looks at the page click is on and assumes that page has been received from server
                        // find a better way to do this
                        if (Browser.BrowserName.Equals("safari"))
                            Thread.Sleep(2000);
                    }
                    catch (ElementNotVisibleException enve)
                    {
                        try { ExecuteScript(_testObject, "arguments[0].click();"); }
                        catch { throw enve; }

                    }
                    catch (Exception e)
                    {
                        if (e.Message.ToLower().Contains(Exceptions.ERROR_NORESPONSEURL))
                        {
                            _testObject.Click();
                        }
                        else
                        {
                            throw;
                        }
                    }
                }

                //measure total time and raise exception if timeout is more than the allowed limit
                DateTime finishTime = DateTime.Now;
                double totalTime = (finishTime - startTime).TotalSeconds;
                if (keyWordDic != null)
                    foreach (string modifiervalue in keyWordDic.Values)
                    {
                        if (modifiervalue.ToLower().Contains("timeout="))
                        {
                            double timeout = double.Parse(modifiervalue.Split('=').Last());
                            if (totalTime > timeout)
                            {
                                throw new Exception("Page load took " + totalTime.ToString(CultureInfo.InvariantCulture) + " seconds to load against expected time of " + timeout + " seconds.");
                            }
                            Property.Remarks = "Page load took " + totalTime.ToString(CultureInfo.InvariantCulture) + " seconds to load against expected time of " + timeout + " seconds.";
                        }
                    }
            }
            catch (Exception e)
            {
                if (_objDataRow.ContainsKey(KryptonConstants.TEST_OBJECT))
                {
                    KryptonException.Writeexception(e);
                    throw new NoSuchElementException(Utility.GetCommonMsgVariable("KRYPTONERRCODE0067").Replace("{MSG3}", _objDataRow[KryptonConstants.TEST_OBJECT]).Replace("{MSG4}", _objDataRow["parent"]).Replace("{MSG1}", AttributeType).Replace("{MSG2}", Attribute).Replace("{ErrorMsg}", e.Message)); // added by
                }
                throw;
            }
//.........这里部分代码省略.........
开发者ID:Thinksys,项目名称:krypton,代码行数:101,代码来源:TestObject.cs

示例14: 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

示例15: MouseOver

 public static void MouseOver(this IWebElement element)
 {
     IWebDriver driver = WebDriverTestBase.driver;
     var action = new Actions(driver).MoveToElement(element);
     Thread.Sleep(2000);
     action.Build().Perform();
 }
开发者ID:tokarthik,项目名称:ProtoTest.Golem,代码行数:7,代码来源:WebDriverExtensions.cs


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