What is the best way to use I have been getting Timeout excption and below is the code I am using to FindElement.
if i use Thread.Sleep(8000) or 6000 its working as excepted but Its scattered all over my code and its hard to maintain ... is there any elegant solution for this problem?
public IWebElement GetFindElement(By locator)
{
WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(20));
IWebElement myDynamicElement = wait.Until<IWebElement>((d) =>
{
return d.FindElement(locator);
});
return myDynamicElement;
}
Error:
[System.TimeoutException] = {"Timed out after 20 seconds"}