As previously explained, we should work with the FindElements method, only if we need to work with a list of tags or multiple elements.


Code Examples
Example no'1: Locating table values
The following code will examine each row on table and print it to a local file:
StreamWriter sw = new StreamWriter(@"C:\Debugg.txt", true);
WebElement = Firefox.FindElement(By.XPath("/html/body/table/……"));
IList<IWebElement> ListOfElements = WebElement.FindElements(By.TagName("tr"));
foreach (var item in ListOfElements)
{
sw.WriteLine(item.Text);
}
Example no'2: Locating multiple elements using a specific attribute
The following code will search for all the <Input> elements that have the 'name' attribute (Ignoring the attribute value).
IList<IWebElement> ListOfElements = Firefox.FindElements(By.XPath("input[@name]"));
No comments:
Post a Comment