I am writing a test where I want to verify that an element is NOT present on a page (displayed or otherwise). I've read in various articles (like this one) how to do the element detection with a list that's empty or not. That works just fine for the opposite test that verifies the elements ARE present. However, when the element is not present, I am consistently getting a WebDriverException timeout after 60 secs of spinning: See screenshot here
The element detection function is as such:
public bool isButtonPresent(string buttonType)
{
switch (buttonType)
{
case "Button 1":
return !(Driver.FindElements(By.Id("Button 1 ID Here")).Count == 0);
case "Button 2":
return !(Driver.FindElements(By.Id("Button 2 ID Here")).Count == 0);
case "Button 3":
return !(Driver.FindElements(By.Id("Button 3 ID Here")).Count == 0);
}
return false;
}
Thank you for your time!