I'm getting a stackoverflow exception on a if/else statement..
Example of code:
if (driver.FindElements(By.XPath("//*[@id='modal']/div/div/div/p[contains(text(), 'Hello World')]")).Count != 0)
{
Console.WriteLine("Hello World");
}
else
{
RunOtherFunction();
}
highlighted error code is -
if (driver.FindElements(By.XPath("//*[@id='modal']/div/div/div/p[contains(text(), 'Hello World')]")).Count != 0)
so clearly it's throwing a exception due to not finding the specified element but I have that covered with an else statement?
so I don't understand why it's throwing an exception because if Element isn't found then it should execute " RunOtherFunction(); " instead it's throwing exception?