I am using selenium WebDriverWait object to dynamically control the timeout for object detection in my code. But this object is timing out before the timespan specified in WebDriverWait object is spent. For ex. I have object initialized with 10 seconds timeout time span but object is timing out in around 2 seconds.
Here is my code
WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10));
try
{
wait.Until(drv => (drv.FindElement(By.XPath(".//*[@class='TopTitle']")))); //drv.FindElement(By.XPath(".//*[@class='TopTitle']")) throws exception
}
catch
{
//exception handlers
}
I am running it in debug mode and i can clearly see drv.FindElement(By.XPath(".//*[@class='TopTitle']")) within 2-3 seconds
Exception and stack trace:
Unable to locate element: {"method":"xpath","selector":".//*[@class='TopTitle']"}
at OpenQA.Selenium.Remote.RemoteWebDriver.UnpackAndThrowOnError(Response errorResponse)
at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandToExecute, Dictionary parameters)
at OpenQA.Selenium.Remote.RemoteWebDriver.FindElement(String mechanism, String value)
at OpenQA.Selenium.Remote.RemoteWebDriver.FindElementByXPath(String xpath)
at OpenQA.Selenium.By.<>c_DisplayClasse.b_c(ISearchContext context)
at OpenQA.Selenium.By.FindElement(ISearchContext context)
at OpenQA.Selenium.Remote.RemoteWebDriver.FindElement(By by)
at VS_UnitTest.Navigation.<>c_DisplayClass2.b_0(IWebDriver drv) in c:\Git\WebadminTests\WebAdminTests\Navigation.cs:line 511
at OpenQA.Selenium.Support.UI.DefaultWait.Until[TResult](Func condition)