Saturday, February 25, 2017

Lesson #14 - Elements search using the FindElements function (C#)

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)

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

My Presentations