I work with selenium and I use the FindElements function, so I get an element that implements the IReadOnlyCollection interface. I want to iterate over the list, but it seems that IReadOnlyCollection has no method, for example Get (int index) or implementation of operation [].
I want to avoid converting the result to a list or array, since I just want to access the elements to read them.
Currently, I do not want to use foreach, since I need to manage the index, so I can add these elements to another array.
This is what I want to do:
public void fillMatrix(){ IReadOnlyCollection<IWebElement> rows = Driver.FindElements(By.XPath("./*/tr")); IReadOnlyCollection<IWebElement> elements; matrix = new IControl[rows.Count()][]; for(int i = 0; i < matrix.Count(); ++i){ matrix[i] = rows[i].FinElements("./td").toArray(); } }
thanks
Yoiku source share