OpenQA.Selenium.By.Id C# (CSharp) Méthode

Id() public static méthode

Gets a mechanism to find elements by their ID.
public static Id ( string idToFind ) : By
idToFind string The ID to find.
Résultat By
        public static By Id(string idToFind)
        {
            if (idToFind == null)
            {
                throw new ArgumentNullException("idToFind", "Cannot find elements with a null id attribute.");
            }

            By by = new By();
            by.findElementMethod = (ISearchContext context) => ((IFindsById)context).FindElementById(idToFind);
            by.findElementsMethod = (ISearchContext context) => ((IFindsById)context).FindElementsById(idToFind);

            by.description = "By.Id: " + idToFind;
            return by;
        }

Usage Example

Exemple #1
0
        ///
        //Methods
        //
        public void SetupGatedAccess()
        {
            driver.FindElement(_featuresLeftPanelIcon).Click();
            driver.FindElement(_hardwareACT365FeatureCheckbox).Click();
            driver.FindElement(_hardwareLightingFeatureCheckbox).Click();
            driver.FindElement(_featureSaveButton).Click();
            driver.FindElement(_bookingLeftPanelIcon).Click();
            driver.FindElement(_bookingSettingsHyperLink).Click();
            driver.FindElement(_manageBasicSettingsOnBookingPageButton).Click();

            IReadOnlyCollection <IWebElement> elements = driver.FindElements(By.CssSelector(".panel:nth-child(2) h2"));

            Console.WriteLine(elements);
            Assert.IsTrue(elements.Count > 0);
            Assert.IsTrue(driver.FindElement(By.CssSelector(".radio-inline .checked")).Enabled);
            var value = driver.FindElement(By.Id("select2-Hardware_Act365_SiteID-container")).Text;

            Assert.AreEqual("SportLabs", value);

            driver.FindElement(_saveBasicSettings).Click();
            driver.FindElement(_bookingSettingsHyperLink).Click();
            driver.FindElement(_bookingManageCourtsLink).Click();
            driver.FindElement(By.CssSelector(".select2-container--focus .select2-selection__rendered")).Click();
            var gateValueText = driver.FindElement(By.CssSelector(".select2-container--focus .select2-selection__choice")).Text;

            Assert.AreSame("Door Controller-3(Circuit-1)", gateValueText);
            driver.FindElement(By.CssSelector(".form-actions > .btn")).Click();
            IReadOnlyCollection <IWebElement> elements1 = driver.FindElements(By.CssSelector(".modal-title:nth-child(2)"));

            Console.WriteLine(elements1);

            Assert.IsTrue(elements1.Count > 0);

            driver.FindElement(_featuresLeftPanelIcon).Click();
            driver.FindElement(_hardwareACT365FeatureCheckbox).Click();
            driver.FindElement(_hardwareLightingFeatureCheckbox).Click();
            driver.FindElement(_featureSaveButton).Click();
        }
All Usage Examples Of OpenQA.Selenium.By::Id