I have written a method IsElementPresent which returns true/false whether element is being displayed or not.
Here is my method
public static bool IsElementPresent(this IWebElement element)
{
try
{
return element.Displayed;
}
catch (Exception)
{
return false;
}
}
Now sometimes when it should return false, element.Displayed is waiting approx 20 seconds (found thru debugging) before catching Exception and returning false. If it finds element, it is working fine.
I also changed code to :
public static bool IsElementPresent(this IWebElement element)
{
try
{
WebDriverWait wait = new WebDriverWait(DriverContext.Driver, TimeSpan.FromSeconds(0.1));
wait.Until(ExpectedConditions.ElementToBeClickable(element));
return true;
}
catch (Exception)
{
return false;
}
}
Now same wait is happening in Wait.Until line. Code is working fine but just unwanted delays when it does not find element. Does it matter how element is found. This particular delay is happening when element is found by class. Most of other elements are found using xpath, css or id. Let me know if I missed any info. Using VS community 15.5.6
"District"
Please correct the errors in the excel File. – Rutwik Feb 23 '18 at 22:02