I am getting \"index out of range\" from this loop. But I need to use new elements that loop founds, how do I do that? Please help to fix the problem
int lin
int linkCount = driver.FindElements(By.CssSelector("a[href]")).Count;
List links = new List();
for (int i = 0; i < linkCount; i++)
{
List linksToClick = driver.FindElements(By.CssSelector("a[href]")).ToList();
if (linksToClick.Count < i)
links.Add(linksToClick[i].GetAttribute("href"));
}
This might help with the out of range exception. Doing this allows you to create a list of type: string without having to explicitly define the size of the list