I have another requirement like this in my c# selenium application. Since there are so many content in my webpage table, it will be quite nice to sort it based on the app name.
First of all, HTML code is far more concise than showing the business model in order to illustrate your problem. Please post it if possible.
Now for this question, what you are trying to do exactly? I can only make comments based on the code you provided.
// are you sure want to get all spans? This will get you lots more unrelated ones
// please try use xpath or css selector to only get the ones related
IList spanList = driver.FindElements(By.TagName("span"));
// now you want loop through each of them, check if text == App4 as an example
foreach (IWebElement span in spanList) {
if (span.Text == "App4") {
// click the span with text App4
span.Click(); // not sure what you want to click here, please clarify
}
}
// version using Linq
// spanList.First(span => span.Text == "App4").Click();