I have this block UI overlay, that sometimes when I try to click on a item(button or anything) it's superimposes or obscures this action, so whenever I try to click I received this ElementClickInterceptedException. Element Obscured.
I want to make a if, that IF this error is received wait until this BLOCK UI class disappears, then try to click it again.
But with this logic, The error is still received and the framework fails to continue, throws the error and pass to the next TestCase
if (driver.FindElement(By.ClassName("block-ui-overlay")).Displayed)
{
WebDriverWait waitForElement = new WebDriverWait(driver, TimeSpan.FromSeconds(5000));
waitForElement.Until(ExpectedConditions.InvisibilityOfElementLocated(By.ClassName("blockUI blockOverlay")));
}
managedg.MAN_DistGroups.Click();
Fluentwait:
public static void BlockUIWait(IWebDriver driver , string selector)
{
DefaultWait<IWebDriver> fluentWait = new DefaultWait<IWebDriver>(driver);
fluentWait.Timeout = TimeSpan.FromSeconds(5);
fluentWait.PollingInterval = TimeSpan.FromMilliseconds(150);
fluentWait.IgnoreExceptionTypes(typeof(ElementClickInterceptedException));
fluentWait.Until(ExpectedConditions.ElementToBeClickable(driver.FindElement(By.CssSelector(selector))));
Result message:
OpenQA.Selenium.ElementClickInterceptedException : Element <div class="ng-scope">
is not clickable at point (404,613) because another element <div class="blockUI blockOverlay">
obscures it