This code example uses the FindElement method to locate an element by its ID attribute. The ID of the element is provided as an argument to the By.Id() method. Example 2: Finding an element by its CSS selectorC#
This code example uses the FindElement method to locate an element by its CSS selector. The CSS selector is provided as an argument to the By.CssSelector() method. Example 3: Finding an element by its XPathC# IWebElement element = driver.FindElement(By.XPath("//div[@class='example-class']")); ``` This code example uses the FindElement method to locate an element by its XPath expression. The XPath expression is provided as an argument to the By.XPath() method. Package/Library: Selenium.WebDriver.