-1

Sleep()` to it works, but without them it doesn't works, I have tried with differetn methods like, visibility, elementtobeclickeable and other but the problem is that the element is not ready to clic because is making a fade off.

_wait.Until(SeleniumExtras.WaitHelpers.
    ExpectedConditions.PresenceOfAllElementsLocatedBy(By.XPath("//*[@id=\"DataTables_Table_7_wrapper\"]/div[2]/div[1]/div/table/thead/tr/th[1]/input")));

//Thread.Sleep(1000);
WEValuador.ChkBoxAllRefacciones.Click();
WEValuador.BtnModificar.Click();

_wait.Until(SeleniumExtras.WaitHelpers.
    ExpectedConditions.PresenceOfAllElementsLocatedBy(By.XPath("/html/body/div[5]/a[4]/span")));

//Thread.Sleep(1000);
WEValuador.BtnAutorizacion.Click();

_wait.Until(SeleniumExtras.WaitHelpers.
    ExpectedConditions.PresenceOfAllElementsLocatedBy(By.XPath("/html/body/div[5]/a[1]/span")));

//Thread.Sleep(1000);
WEValuador.BtnAutorizado.Click();

ASU.AssertMsjs();

This is the error:

Message: 
    System.Reflection.TargetInvocationException : Exception has been thrown by the target of an invocation.
      ----> System.InvalidOperationException : unknown error: Element <input class="selected-item-all select-checkbox" data="" type="checkbox" name="" value=""> is not clickable at point (330, 490). Other element would receive the click: <div class="modal show" id="SpinnerLoader" tabindex="-1" role="dialog" aria-labelledby="loadMeLabel" data-backdrop="static" data-keyboard="false" style="padding-right: 17px; display: block;">...</div>
      (Session info: chrome=85.0.4183.83)
      (Driver info: chromedriver=2.37.543627 (63642262d9fb93fb4ab52398be4286d844092a5e),platform=Windows NT 10.0.18362 x86_64)
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352

3 Answers3

0

To Click() on any individual element instead of PresenceOfAllElementsLocatedBy() you have to induce WebDriverWait for the ElementToBeClickable() and you can use the following Locator Strategy:

_wait.Until(SeleniumExtras.WaitHelpers.ExpectedConditions.ElementToBeClickable(By.XPath("//*[@id=\"DataTables_Table_7_wrapper\"]/div[2]/div[1]/div/table/thead/tr/th[1]/input")));
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
0

In this cases the JavaScript Executor really helps to solve the problem. Instead of wait for ElementToBeClickable and Visible. Use Java script

Java -

WebElement element = driver.findElement(By.id("gbqfd"));
JavascriptExecutor executor = (JavascriptExecutor)driver;
executor.executeScript("arguments[0].click();", element);

C# -

IJavascriptExecutor jse = (IJavascriptExecutor) driver; 
jse.executeScript("arguments[0].click()= element ); 
Joe Mayo
  • 7,501
  • 7
  • 41
  • 60
Avinash
  • 1
  • 1
0
   This was my solution, you could to quit thread.sleep();

public static IWebElement SafeWaitForDisplayed(IWebElement webElement) {

        var w = new DefaultWait<IWebElement>(webElement);
        w.Timeout = TimeSpan.FromSeconds(30);
        w.IgnoreExceptionTypes(typeof(NoSuchElementException), typeof(StaleElementReferenceException),typeof(System.Reflection.TargetInvocationException));

        return w.Until(ctx =>
        {
            var elem = webElement;
            if (elem.Displayed) {
                Thread.Sleep(500);
                return elem;
            }
            else
                return null;
        });

        //Thread.Sleep(100);


    }