-1

I'm trying to click a button from a modal dialog, but when it's the time to click on it, i have the next error:

OpenQA.Selenium.ElementClickInterceptedException : element click intercepted: Element <button onclick="Activar(193);" class="button mx-1" title="Recover">...</button> is not clickable at point (1206, 319). Other element would receive the click: <div class="ui-widget-overlay" style="width: 1349px; height: 613px; z-index: 1001;"></div>

I know that i need to use a wait helper, but i don't know exactly how to use it, this is my code with the wait helper:

 public ConfigurationUsuario HabilitarConfiguracion()
        {
            WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(20));
            iconoActivar.Click();
            driver.SwitchTo().ActiveElement();
            wait.Until(SeleniumExtras.WaitHelpers.ExpectedConditions.ElementToBeClickable(By.XPath("//button[@title='Recover']"))).Click();
            driver.FindElement(By.XPath("//button[@title='Recover']")).Click();
            return new ConfigurationUsuario(driver);
        }

Probably it's because i don't know how use wait helper, but the test don't wait the 20 secods, after 2-3 seconds in the modal dialog, it closes, so if anyone can help me, i would really apreciate it

1
  • if there's a close button for the overlay div, click that first. If not, just use a sleep. A webdriverwait will only wait until the button is clickable. (It is, it's just that another element would receive that click.) Commented Jan 29, 2021 at 19:35

1 Answer 1

2

Try this:

Get a wait for the element displayed:

ex. WaitForElementDisplayed_byXPathTime("//input[@id='id']");

    public static void WaitForElementDisplayed_byXPathTime(string value)
    {
        try
        {
            var wait = new WebDriverWait(driver, new TimeSpan(0, 0, 30));
            wait.Until(webDriver => driver.FindElement(By.XPath(value)).Displayed);
        }
        catch (Exception) { throw; }
    }

Then switch to the popup - In all honesty, this may not even be necessary. Not all popups require you to switch to them.

        public static string SwitchToPopup()
    {
        var mainHandle = driver.CurrentWindowHandle;
        var handles = driver.WindowHandles;

        foreach (var handle in handles)
        {
            if (mainHandle == handle)
            {
                continue;
            }
            driver.SwitchTo().Window(handle);
            Thread.Sleep(1000);
            break;
        }
        var result = Url;
        return result;
       
    }
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.