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


C# Actions.MoveByOffset方法代碼示例

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


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

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

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

示例3: SeleniumAPI_Demo4

        public void SeleniumAPI_Demo4()
        {
            _output.WriteLine("Step 01 : 啟動瀏覽器並打開博客園首頁。");
            IWebDriver driver = new FirefoxDriver();
            driver.Url = "http://www.cnblogs.com";

            _output.WriteLine("Step 02 : 尋找需要操作的頁麵元素。");
            var divText = driver.FindElement(By.Id("site_nav_top"));            
            var point = divText.Location;
            var width = int.Parse(divText.GetCssValue("width").Replace("px", string.Empty));
            
            _output.WriteLine("Step 03 : 選中文本信息。");
            var action = new Actions(driver);
            action
                .MoveByOffset(point.X, point.Y)         //移動鼠標到文本開頭
                .ClickAndHold()                         //按下鼠標    
                .MoveByOffset(point.X + width, point.Y) //移動鼠標到文本結束
                .Release()                              //釋放鼠標
                .Build()
                .Perform();

            System.Threading.Thread.Sleep(5000);
            _output.WriteLine("Step 04 : 關閉瀏覽器。");
            driver.Close();
        }
開發者ID:DemoCnblogs,項目名稱:Selenium,代碼行數:25,代碼來源:Lesson04_05_SeleniumAPI.cs

示例4: DeleteModule

		public void DeleteModule(string moduleNumber)
		{
			Trace.WriteLine(BasePage.TraceLevelComposite + "Delete the Module:");

			SelectFromSettingsMenu(moduleNumber, DeleteOption);

			Actions builder = new Actions(_driver);
			builder.MoveByOffset(300,100).Build().Perform();

			WaitForConfirmationBox(60);
			ClickYesOnConfirmationBox();
		}
開發者ID:kp-xcess,項目名稱:Dnn.Platform,代碼行數:12,代碼來源:Modules.cs

示例5: GenerateTooltipMessages

        private static List<string> GenerateTooltipMessages(IWebDriver driver, List<Point> graph,
            HighchartsPage page)
        {
            Actions action = new Actions(driver);

            action.MoveToElement(page.RootElement, 0, 0)
                .MoveByOffset(graph[0].X, graph[0].Y)
                .Build()
                .Perform();
            List<string> tooltip = new List<string>();
            for (int point = 1; point < graph.Count; point++)
            {
                for (int i = 0; i <= graph[point].X - graph[point - 1].X; i+=Step)
                {
                    action.MoveByOffset(Step, 0).Build().Perform();
                    if (tooltip.LastOrDefault() != page.TooltipElement.Text &&
                        page.TooltipElement.Text.Contains(HighchartsPage.EmployeeKeyword))
                    {
                        tooltip.Add(page.TooltipElement.Text);
                    }
                }
                action.MoveByOffset(0, graph[point].Y - graph[point - 1].Y)
                    .Build()
                    .Perform();
            }
            return tooltip;
        }
開發者ID:Lolmarty,項目名稱:EpamExamThree,代碼行數:27,代碼來源:Program.cs

示例6: moveTo

        public void moveTo(int x, int y)
        {
            int effectiveOffset = 0;
            int step = 1;
            int a = x > 0 ? step : -step;
            int b = y > 0 ? step : -step;

            while (effectiveOffset < Math.Abs(x))
            {
                var build = new Actions(Cons.driver);
                build.MoveByOffset(a, 0).ContextClick().Build().Perform();
                effectiveOffset += step;
            }
            effectiveOffset = 0;
            while (effectiveOffset < Math.Abs(y))
            {
                var build = new Actions(Cons.driver);
                build.MoveByOffset(0, b).ContextClick().Build().Perform();
                effectiveOffset += step;
            }
        }
開發者ID:Polivando,項目名稱:Highcharts,代碼行數:21,代碼來源:Chart.cs


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