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


C# Actions.ClickAndHold方法代码示例

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


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

示例1: TestHtml5CanvasDrawing

        public void TestHtml5CanvasDrawing()
        {
            try
            {
                driver.Navigate().GoToUrl("http://dl.dropbox.com/u/55228056/html5canvasdraw.html");

                //Get the HTML5 Canvas Element
                IWebElement canvas = driver.FindElement(By.Id("imageTemp"));
                //Select the Pencil Tool
                SelectElement drawtool = new SelectElement(driver.FindElement(By.Id("dtool")));
                drawtool.SelectByText("Pencil");

                //Create a Action Chain for Draw a shape on Canvas
                Actions builder = new Actions(driver);
                builder.ClickAndHold(canvas).MoveByOffset(10, 50).
                                             MoveByOffset(50, 10).
                                             MoveByOffset(-10, -50).
                                             MoveByOffset(-50, -10).Release().Perform();

                //Get a screenshot of Canvas element after Drawing and compare it to the base version
                Screenshot ss = ((ITakesScreenshot)driver).GetScreenshot();
                string screenshot = ss.AsBase64EncodedString;
                byte[] screenshotAsByteArray = ss.AsByteArray;
                ss.SaveAsFile(@"c:\tmp\post.png", ImageFormat.Png);
            }
            catch (Exception e)
            {
                Assert.Fail("Test Failed due to exception '" + e.Message + "'");
            }
        }
开发者ID:oluk68,项目名称:SELENIUM2,代码行数:30,代码来源:Html5CanvasDrawing.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: DeleteTask

        private static void DeleteTask(IWebDriver driver, IWebElement task)
        {
            var drag = task.FindElement(By.CssSelector("span.i.drag.project"));
            var drop = driver.FindElement(By.ClassName("trash"));

            var builder = new Actions(driver);
            var dragAndDrop = builder.ClickAndHold(drag)
                .MoveToElement(drop)
                .Release(drag)
                .Build();
            dragAndDrop.Perform();
        }
开发者ID:xcyroo,项目名称:InnovationDay.AcceptanceTesting,代码行数:12,代码来源:AddingTasksTest.cs

示例4: TestClicknHold

        public void TestClicknHold()
        {
            NavigationHelper.NavigateToUrl("http://demos.telerik.com/kendo-ui/sortable/index");
            Actions act = new Actions(ObjectRepository.Driver);
            IWebElement ele = ObjectRepository.Driver.FindElement(By.XPath("//ul[@id='sortable-basic']/li[12]"));
            IWebElement tar = ObjectRepository.Driver.FindElement(By.XPath("//ul[@id='sortable-basic']/li[2]/span"));
            act.ClickAndHold(ele)
                .MoveToElement(tar, 0, 30)
                .Release()
                .Build()
                .Perform();

            Thread.Sleep(10000);
        }
开发者ID:Saltorel,项目名称:BDD-CSharp,代码行数:14,代码来源:TestMouseAction.cs

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

示例6: 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:j0hnsmith,项目名称:Selenium2,代码行数:36,代码来源:BasicMouseInterfaceTest.cs

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

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

示例9: MovePricingSlider

        public void MovePricingSlider(int count, int range)
        {

            if (count <= 5)
                numberofpixels = -150;
            if (count > 5 && count <= 10)
                numberofpixels = -100;
            if (count > 10 && count <= 20)
                numberofpixels = 0;
            if (count > 20 && count <= 30)
                numberofpixels = 20;

            int widthofslidebar = sliderBar.Size.Width;

            //user set
            Actions slider = new Actions(Browser._Driver);
            slider.ClickAndHold(pricingSlider).MoveByOffset(numberofpixels, range).Build().Perform();
            Thread.Sleep(1000);
        }
开发者ID:rohanbaraskar,项目名称:CSharp-Selenium-Sample-Framework,代码行数:19,代码来源:PricingPage.cs

示例10: MoveJQuerySlider

 private void MoveJQuerySlider(IWebDriver driver, IWebElement widget, int x, int y)
 {
     Actions actions = new Actions(driver);
     IAction action = actions.ClickAndHold(widget).MoveByOffset(x, y).Release().Build();
     action.Perform();
 }
开发者ID:CodeCowboyOrg,项目名称:SeleniumTestExamples,代码行数:6,代码来源:SeleniumWebDriverInvokeJavaScript.cs

示例11: BySlaves

 public void BySlaves()
 {
     int slavesCount = 0;
     try
     {
         slavesCount = Convert.ToInt32(ReadFromFile(SettingsFile, "AdditionalSettingsBox")[8]);
         int currentSlavesCount = Convert.ToInt32(GetResourceValue("title=" + '\u0022' + "Количество занятых мест на плантации" + '\u0022' + " style")[0]);
         if (currentSlavesCount <= slavesCount)
         {
             driver.FindElement(By.LinkText("Гавань")).Click();
             driver.FindElement(By.LinkText("Торговая площадка")).Click();
             driver.FindElement(By.XPath(".//option[text()='Раб людишко']")).Click();
             //двигаем бегунок
             IWebElement Slider = driver.FindElement(By.CssSelector(".ui-slider-handle.ui-state-default.ui-corner-all"));
             Actions builder = new Actions(driver);
             IAction dragAndDrop = builder.ClickAndHold(Slider).MoveByOffset(0, 0).MoveByOffset(7, 100).Release().Build();
             dragAndDrop.Perform();
             driver.FindElement(By.XPath(".//input[@value='КУПИТЬ']")).Click();
         }
     }
     catch { }
 }
开发者ID:VitaliiDolotov,项目名称:SBRepo,代码行数:22,代码来源:BotLibrary.cs

示例12: ByKeys

        public void ByKeys()
        {
            if (ReadFromFile(SettingsFile, "UndergroundBox")[6] == "True")
            {
                Random rnd = new Random();
                //смотрим сколько у нас ключей, если 0, то докупаем
                if (Convert.ToInt32(GetResourceValue("Ключ от ворот царства Манаглота")[0]) == 0)
                {
                    try
                    {
                        //устрашатели
                        driver.FindElement(By.Id("top_menu")).FindElement(By.XPath(".//a[@title='Устрашатели']")).Click();
                        System.Threading.Thread.Sleep(rnd.Next(1105, 1199));
                        //оружейная
                        driver.FindElement(By.Id("hover_guild_weapon")).Click();
                        System.Threading.Thread.Sleep(rnd.Next(1105, 1199));
                        //Предметы
                        driver.FindElement(By.LinkText("Предметы")).Click();
                        System.Threading.Thread.Sleep(rnd.Next(1105, 1199));

                        //двигаем бегунок
                        IWebElement Slider = driver.FindElement(By.Id("slider_2")).FindElement(By.TagName("a"));
                        Actions builder = new Actions(driver);
                        IAction dragAndDrop = builder.ClickAndHold(Slider).MoveByOffset(0, 0).MoveByOffset(100, 100).Release().Build();
                        dragAndDrop.Perform();
                        System.Threading.Thread.Sleep(rnd.Next(1105, 1199));

                        //купить
                        driver.FindElement(By.XPath("//input[@value='КУПИТЬ']")).Click();
                    }
                    catch { }
                }
            }
        }
开发者ID:VitaliiDolotov,项目名称:SBRepo,代码行数:34,代码来源:BotLibrary.cs

示例13: LitleGuru

        public void LitleGuru()
        {
            if (Convert.ToBoolean(ReadFromFile(SettingsFile, "AdditionalSettingsBox")[9]) == true)
            {
                while (true)
                {
                    int currenCry = Convert.ToInt32(driver.FindElement(By.Id("crystal")).FindElement(By.TagName("b")).Text.Replace(".", ""));
                    driver.FindElement(By.LinkText("Гавань")).Click();
                    System.Threading.Thread.Sleep(rnd.Next(689, 899));
                    driver.FindElement(By.LinkText("Торговая площадка")).Click();
                    System.Threading.Thread.Sleep(rnd.Next(689, 899));
                    driver.FindElement(By.XPath(".//option[text()='Билет на маленькую поляну']")).Click();

                    while (currenCry > 30)
                    {
                        //двигаем бегунок
                        IWebElement Slider = driver.FindElement(By.CssSelector(".ui-slider-handle.ui-state-default.ui-corner-all"));
                        Actions builder = new Actions(driver);
                        IAction dragAndDrop = builder.ClickAndHold(Slider).MoveByOffset(0, 0).MoveByOffset(200, 150).Release().Build();
                        dragAndDrop.Perform();
                        driver.FindElement(By.XPath(".//input[@value='КУПИТЬ']")).Click();
                        System.Threading.Thread.Sleep(rnd.Next(689, 899));
                        currenCry = Convert.ToInt32(driver.FindElement(By.Id("crystal")).FindElement(By.TagName("b")).Text.Replace(".", ""));
                        if (Convert.ToInt32(GetResourceValue("i33")[0]) > (Convert.ToInt32(GetResourceValue("i33")[1]) - 15))
                        {
                            break;
                        }
                    }
                    SmallFields();
                }
            }
        }
开发者ID:VitaliiDolotov,项目名称:SBRepo,代码行数:32,代码来源:BotLibrary.cs

示例14: BigGuru

        public void BigGuru()
        {
            if (Convert.ToBoolean(ReadFromFile(SettingsFile, "AdditionalSettingsBox")[28]) == true)
            {
                while (true)
                {
                    try
                    {
                        int currenCry = Convert.ToInt32(driver.FindElement(By.Id("crystal")).FindElement(By.TagName("b")).Text.Replace(".", ""));
                        driver.FindElement(By.LinkText("Гавань")).Click();
                        Delays();
                        driver.FindElement(By.XPath("//div[text()='Торговая площадка']")).Click();
                        Delays();
                        driver.FindElement(By.XPath(".//option[text()='Билет на большую поляну']")).Click();

                        while (currenCry > 105)
                        {
                            //двигаем бегунок
                            IWebElement Slider = driver.FindElement(By.CssSelector(".ui-slider-handle.ui-state-default.ui-corner-all"));
                            Actions builder = new Actions(driver);
                            IAction dragAndDrop = builder.ClickAndHold(Slider).MoveByOffset(0, 0).MoveByOffset(40, 40).Release().Build();
                            dragAndDrop.Perform();
                            SmallDelays();
                            driver.FindElement(By.XPath(".//input[@value='КУПИТЬ']")).Click();
                            Delays();
                            currenCry = Convert.ToInt32(driver.FindElement(By.Id("crystal")).FindElement(By.TagName("b")).Text.Replace(".", ""));
                            if (Convert.ToInt32(GetResourceValue("i34")[0]) > (Convert.ToInt32(GetResourceValue("i34")[1]) - 15))
                            {
                                break;
                            }
                        }
                        BigFields(0);
                    }
                    catch { }
                }
            }
        }
开发者ID:VitaliiDolotov,项目名称:NSB,代码行数:37,代码来源:BotLibrary.cs

示例15: DragAndDrop

        public static void DragAndDrop(this IWebElement element, IWebElement e1, IWebElement e2)
        {
            Actions builder = new Actions(Browser.Driver);

            builder.ClickAndHold(e1).MoveToElement(e2).Release(e2).Build().Perform();
        }
开发者ID:dnamartin,项目名称:Automation,代码行数:6,代码来源:Extensions.cs


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