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


C# Actions.Click方法代碼示例

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


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

示例1: TheXTest

        public void TheXTest()
        {
            
            driver = new FirefoxDriver();
            IJavaScriptExecutor js = driver as IJavaScriptExecutor;
            Login u = new Login(driver);
            string login1 = "guest";
            u.get().login(login1, login1).click();//вход на сайт
            driver.FindElement(By.Id("sovzond_widget_SimpleButton_104")).Click();
            Thread.Sleep(5000);
            IWebElement element = driver.FindElement(By.Id("sovzond_widget_SimpleButton_0"));
            var builder = new Actions(driver);
            builder.Click(element).Perform();
            IList<IWebElement> el = driver.FindElements(By.ClassName("svzLayerManagerItem"));
            for (int n = 0; n < el.Count; n++)
            {
                if (el[0].Text != "Google") Assert.Fail("не найден Google");
                if (el[4].Text != "Росреестр") Assert.Fail("не найден Росреестр");
                if (el[5].Text != "OpenStreetMap") Assert.Fail("не найден OpenStreetMap");
                if (el[6].Text != "Топооснова") Assert.Fail("не найден Топооснова");
            }
                IWebElement element1 = driver.FindElement(By.Id("dijit_form_RadioButton_3"));
                builder.Click(element1).Perform();
               
               Thread.Sleep(5000);  
               string h= (string)js.ExecuteScript("return window.portal.stdmap.map.baseLayer.div.id.toString()");


            
        }
開發者ID:sovzond,項目名稱:darya,代碼行數:30,代碼來源:UnitTest2.cs

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

示例3: ShouldAllowSelectingMultipleItems

        public void ShouldAllowSelectingMultipleItems()
        {
            driver.Url = selectableItemsPage;

            IWebElement reportingElement = driver.FindElement(By.Id("infodiv"));

            Assert.AreEqual("no info", reportingElement.Text);

            ReadOnlyCollection<IWebElement> listItems = driver.FindElements(By.TagName("li"));

            Actions actionBuider = new Actions(driver);
            IAction selectThreeItems = actionBuider.KeyDown(Keys.Control)
                .Click(listItems[1])
                .Click(listItems[3])
                .Click(listItems[5])
                .KeyUp(Keys.Control).Build();

            selectThreeItems.Perform();

            Assert.AreEqual("#item2 #item4 #item6", reportingElement.Text);

            // Now click on another element, make sure that's the only one selected.
            actionBuider.Click(listItems[6]).Build().Perform();
            Assert.AreEqual("#item7", reportingElement.Text);
        }
開發者ID:Goldcap,項目名稱:Constellation,代碼行數:25,代碼來源:CombinedInputActionsTest.cs

示例4: ShouldAllowSelectingMultipleItems

        public void ShouldAllowSelectingMultipleItems()
        {
            if (!IsNativeEventsEnabled || (!Platform.CurrentPlatform.IsPlatformType(PlatformType.Linux)))
            {
                Assert.Ignore("Skipping ShouldAllowSelectingMultipleItems: Only works with native events on Linux.");
            }

            driver.Url = selectableItemsPage;

            IWebElement reportingElement = driver.FindElement(By.Id("infodiv"));

            Assert.AreEqual("no info", reportingElement.Text);

            ReadOnlyCollection<IWebElement> listItems = driver.FindElements(By.TagName("li"));

            Actions actionBuider = new Actions(driver);
            IAction selectThreeItems = actionBuider.KeyDown(Keys.Control)
                .Click(listItems[1])
                .Click(listItems[3])
                .Click(listItems[5])
                .KeyUp(Keys.Control).Build();

            selectThreeItems.Perform();

            Assert.AreEqual("#item2 #item4 #item6", reportingElement.Text);

            // Now click on another element, make sure that's the only one selected.
            actionBuider.Click(listItems[6]).Build().Perform();
            Assert.AreEqual("#item7", reportingElement.Text);
        }
開發者ID:draculavlad,項目名稱:selenium,代碼行數:30,代碼來源:CombinedInputActionsTest.cs

示例5: ShouldAllowClickingOnFormElements

        public void ShouldAllowClickingOnFormElements()
        {
            if (!IsNativeEventsEnabled || (!Platform.CurrentPlatform.IsPlatformType(PlatformType.Linux)))
            {
                Assert.Ignore("Skipping ShouldAllowClickingOnFormElements: Only works with native events on Linux.");
            }

            driver.Url = formSelectionPage;

            ReadOnlyCollection<IWebElement> options = driver.FindElements(By.TagName("option"));

            Actions actionBuider = new Actions(driver);
            IAction selectThreeOptions = actionBuider.Click(options[1])
                .KeyDown(Keys.Shift)
                .Click(options[2])
                .Click(options[3])
                .KeyUp(Keys.Shift).Build();

            selectThreeOptions.Perform();

            IWebElement showButton = driver.FindElement(By.Name("showselected"));
            showButton.Click();

            IWebElement resultElement = driver.FindElement(By.Id("result"));
            Assert.AreEqual("roquefort parmigiano cheddar", resultElement.Text, "Should have picked the last three options.");
        }
開發者ID:draculavlad,項目名稱:selenium,代碼行數:26,代碼來源:CombinedInputActionsTest.cs

示例6: ClickCategoryTree

 private static void ClickCategoryTree(string category)
 {
     var expandNode = driver.FindElement(By.XPath("//div[@id='navigation']//span[text()='" + category + "']/parent::*/parent::*"), 5);
     Console.WriteLine(expandNode.GetAttribute("class"));
     var actions = new Actions(driver);
     actions.MoveToElement(expandNode);
     actions.Click();
     actions.Perform();
 }
開發者ID:ntdung,項目名稱:EPiServerCommerce75,代碼行數:9,代碼來源:Program.cs

示例7: OpenBaseLayers

 private void OpenBaseLayers()
 { 
     driver.FindElement(By.CssSelector(locationSlideMenu)).Click();    
     IWebElement elementBaseLayer = driver.FindElement(By.CssSelector(locationBaseLayers));
     var builderBaseLayers = new Actions(driver);
     System.Threading.Thread.Sleep(1000);
     builderBaseLayers.Click(elementBaseLayer).Perform(); 
     System.Threading.Thread.Sleep(1000);
 }
開發者ID:sovzond,項目名稱:pavel,代碼行數:9,代碼來源:TestBaseLayers.cs

示例8: KeyUpAndKeyDown

        public void KeyUpAndKeyDown()
        {
            var list = this.MainWindow.FindElement(By.Id("TextListBox"));
            var items = list.FindElements(By.ClassName("ListBoxItem"));
            var first = items.First();
            var random = items.ElementAt(3);
            var actions = new Actions(this.Driver);

            actions.Click(first).KeyDown(Keys.Shift).Click(random).KeyUp(Keys.Shift).Perform();

            var selectedItemsCount = list.FindElements(By.ClassName("ListBoxItem")).Count(item => item.Selected);

            Assert.AreEqual(4, selectedItemsCount);
        }
開發者ID:amolpathak224,項目名稱:Winium.Desktop,代碼行數:14,代碼來源:ActionChainsTests.cs

示例9: CreateInd

        public static void CreateInd(TitlesList.EnumAdminLeftBar pageName)
        {
            // ReadOnlyCollection<IWebElement> topBarElements;
            Driver.Wait(2);
            /*Array enumNamesTopBar = Enum.GetNames(typeof(TitlesList.EnumTitlesTopBar));
            int pos = Array.IndexOf(enumNamesTopBar, pageName);
            if (pos > -1)
            {
                topBarElements = Driver.Instance.FindElements(By.ClassName("topbar"));
            }
            else
            {
                topBarElements = Driver.Instance.FindElements(By.ClassName("admin-left-navigation-panel"));
            }*/
             /*  var barElements = Driver.Instance.FindElements(By.ClassName("admin-inner-page-content"));
            int valueOfEnum = (int)pageName;
            // string pageNameString = Enum.GetName(typeof(TitlesList.EnumAdminLeftBar), valueOfEnum).ToString();
            string pageNameString = pageName.ToString();
            pageNameString = pageNameString.Replace('_', ' ');

            foreach (var row in barElements)
            {
                ReadOnlyCollection<IWebElement> links = null;
                //  Driver.NoWait(() => links = row.FindElements(By.LinkText(pageName)));

                links = row.FindElements(By.PartialLinkText("Add new"));
                if (links.Count > 0)
                {
                    links[0].Click();
                }

            }*/
            var link1 = Driver.Instance.FindElement(By.LinkText("Add new"));
            link1.Click();
            Driver.Wait(2);
            var inputs = Driver.Instance.FindElements(By.TagName("input"));
            inputs[0].SendKeys("Test Title");
            inputs[1].SendKeys("Test Id");
            var inputs1 = Driver.Instance.FindElement(By.CssSelector("body>div:nth-child(1)>section >div.admin-pages-content>div.admin-inner-page-content>div>form>fieldset>div:nth-child(2)>div:nth-child(8)>span.k-widget.k-dropdown.k-header.ng-pristine.ng-valid.ng-touched>span>span.k-input.ng-scope"));

            Actions action = new Actions(Driver.Instance);
                   action.MoveToElement(inputs1);
                   action.Perform();
                   action.Click();
            action.Perform();
        }
開發者ID:KorsunPavel,項目名稱:IndicatorsTestAutomotionTTF,代碼行數:46,代碼來源:Indicators.cs

示例10: TestRowSelectionUsingControlKey

        public void TestRowSelectionUsingControlKey()
        {
            var tableRows = driver.FindElements(By.XPath("//table[@class='iceDatTbl']/tbody/tr"));

            //Select second and fourth row from table using Control Key.
            //Row Index start at 0
            Actions builder = new Actions(driver);
            builder.Click(tableRows[1])
                    .KeyDown(Keys.Control)
                    .Click(tableRows[3])
                    .KeyUp(Keys.Control)
                    .Build().Perform();

            //Verify Selected Row table shows two rows selected
            var rows = driver.FindElements(By.XPath("//div[@class='icePnlGrp exampleBox']/table[@class='iceDatTbl']/tbody/tr"));
            Assert.AreEqual(2,rows.Count);
        }
開發者ID:vikramuk,項目名稱:Selenium,代碼行數:17,代碼來源:RowSelectionTests.cs

示例11: TestRowSelectionUsingShiftKey

        public void TestRowSelectionUsingShiftKey()
        {
            var tableRows = driver.FindElements(By.XPath("//table[@class='iceDatTbl']/tbody/tr"));

            //Select first row to fourth row from Table using Shift Key
            //Row Index start at 0
            Actions builder = new Actions(driver);
            builder.Click(tableRows[0])
                    .KeyDown(Keys.Shift)
                    .Click(tableRows[1])
                    .Click(tableRows[2])
                    .Click(tableRows[3])
                    .KeyUp(Keys.Shift)
                    .Build().Perform();

            var rows = driver.FindElements(By.XPath("//div[@class='icePnlGrp exampleBox']/table[@class='iceDatTbl']/tbody/tr"));
            Assert.AreEqual(4,rows.Count);
        }
開發者ID:vikramuk,項目名稱:Selenium,代碼行數:18,代碼來源:RowSelectionTests.cs

示例12: ShouldAllowClickingOnFormElements

        public void ShouldAllowClickingOnFormElements()
        {
            driver.Url = formSelectionPage;

            ReadOnlyCollection<IWebElement> options = driver.FindElements(By.TagName("option"));

            Actions actionBuider = new Actions(driver);
            IAction selectThreeOptions = actionBuider.Click(options[1])
                .KeyDown(Keys.Shift)
                .Click(options[2])
                .Click(options[3])
                .KeyUp(Keys.Shift).Build();

            selectThreeOptions.Perform();

            IWebElement showButton = driver.FindElement(By.Name("showselected"));
            showButton.Click();

            IWebElement resultElement = driver.FindElement(By.Id("result"));
            Assert.AreEqual("roquefort parmigiano cheddar", resultElement.Text, "Should have picked the last three options.");
        }
開發者ID:Goldcap,項目名稱:Constellation,代碼行數:21,代碼來源:CombinedInputActionsTest.cs

示例13: ToggleNavigationPan

        static void ToggleNavigationPan()
        {
            var span = driver.FindElement(By.XPath("//div[@id='applicationContainer']//div[@id='/episerver/commerce/catalog_rootContainer']//div[@class='dijit epi-globalToolbar dijitToolbar']//span[@class='dijitReset dijitInline dijitButtonNode']"), 5);

            var actionPan = new Actions(driver);
            actionPan.MoveToElement(span);
            actionPan.Click();
            actionPan.Perform();

            var pin = driver.FindElement(
                By.XPath(
                    "//div[@id='navigation']//div[@class='epi-pinnableToolbar']//div[@class='epi-toolbarGroup epi-toolbarTrailing']/span[2]//span[@class='dijitReset dijitInline dijitButtonNode']"), 5);
            var actionPin = new Actions(driver);
            actionPin.MoveToElement(pin);
            actionPin.Click();
            actionPin.Perform();
        }
開發者ID:ntdung,項目名稱:EPiServerCommerce75,代碼行數:17,代碼來源:Program.cs

示例14: OpenGlobalMenu

        static void OpenGlobalMenu()
        {
            var link = driver.FindElement(By.XPath("//div[@id='globalMenuContainer']//a"), 5);

            Actions actions2 = new Actions(driver);
            actions2.MoveToElement(link);
            actions2.Click().Perform();

            //var contentTypeTab = driver.FindElement(By.LinkText("Content Type"));
            //actions2.MoveToElement(contentTypeTab);
            //actions2.Click().Perform();
        }
開發者ID:ntdung,項目名稱:EPiServerCommerce75,代碼行數:12,代碼來源:Program.cs

示例15: MouseClick

 public void MouseClick(IWebElement element)
 {
     Console.WriteLine("Click the mouse on the element");
     var builder = new Actions(Driver);
     builder.Click(element).Perform();
 }
開發者ID:AlexNaryzhny,項目名稱:helloci,代碼行數:6,代碼來源:BasePage.cs


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