Im trying to automaticly test all the links on a site. But the problem is that my foreach loop stops after the first click.
When I Console.log the attribute it writes out all the links but wont do the same when its time to Click around :)
This logs out all the links.
[FindsBy(How = How.TagName, Using = "a")]
public IWebElement hrefClick { get; set; }
public void TestT2Links()
{
foreach (IWebElement item in PropertiesCollection.driver.FindElements(By.TagName("a")))
{
Console.WriteLine(item.GetAttribute("href"));
}
}
But when im trying to Click() function it only clicks the first link.
[FindsBy(How = How.TagName, Using = "a")]
public IWebElement hrefClick { get; set; }
public void TestT2Links()
{
foreach (IWebElement item in PropertiesCollection.driver.FindElements(By.TagName("a")))
{
hrefClick.Click();
Console.WriteLine(item.GetAttribute("href"));
}
}
I also tried the back method to back navigate after every click but also useless and wrong :(
PropertiesCollection.driver.Navigate().Back();
Any tips?