当前位置: 首页>>代码示例>>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;未经允许,请勿转载。