I already searched many solutions and couldn't find any that helped me.
I gather data from a iWebElement, add it to a List, convert it to string and later to a List<string> that's when I try to do . Distinct() resulting on nothing.
var h1Heading = driver.FindElements(By.XPath("//h1"));
ListOfKeywords.AddRange(h1Heading);
foreach (IWebElement keywords in ListOfKeywords)
{
cleaned.Add(keywords.Text);
}
cleaned.Distinct().ToList();
Distinct()returns an ienumerable with no duplicates. you have to assign it to a variable, though, it does not change the original in place - trycleaned = cleaned.Distinct().ToList()