Selenium- Element is not clickable at point (403, 697). Other element would receive the click

-2

I am trying to test using selenium. I want to click a button but i have a loader that wait couple of second before disappear.

Loader element who is overlaying other element.You can see here how loader look like in my page. So i need a help to find a way to wait until this loader disappear to continue my test

image

Error:

OpenQA.Selenium.WebDriverException
  HResult=0x80131500
  Message=unknown error: Element <select _ngcontent-c4="" class="col-xs-8 custom-input-styles custom-select ng-touched ng-dirty ng-valid" formcontrolname="organizationType">...</select> is not clickable at point (441, 620). Other element would receive the click: <div _ngcontent-c2="" class="loader-wrapper ng-trigger ng-trigger-visibilityChanged ng-animating" style="">...</div>
  (Session info: chrome=68.0.3440.106)
  (Driver info: chromedriver=2.40.565498 (ea082db3280dd6843ebfb08a625e3eb905c4f5ab),platform=Windows NT 10.0.17134 x86_64)
  Source=WebDriver
  StackTrace:
   at OpenQA.Selenium.Remote.RemoteWebDriver.UnpackAndThrowOnError(Response errorResponse)
   at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters)
   at OpenQA.Selenium.Remote.RemoteWebElement.Execute(String commandToExecute, Dictionary`2 parameters)
   at OpenQA.Selenium.Remote.RemoteWebElement.Click()
   at BnI.UITests.Register.TheProceedRedirectTest() in C:\Users\me\UITests\Register.cs:line 86
c#
selenium
asked on Stack Overflow Aug 24, 2018 by jack daniels • edited Aug 24, 2018 by jack daniels

2 Answers

0

If you know the class name of the loader, you just can add the below code snippet (for c#):

WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(seconds));
            var waiter = wait.Until(ExpectedConditions.InvisibilityOfElementLocated(By.ClassName(cssClass)));
            return waiter;
answered on Stack Overflow Aug 24, 2018 by Techno • edited Aug 24, 2018 by Mike
0

You just need to wait for jquery to finish its job. Here's a sample java implementation of the solution that I have come up.

I don't use WebDriverWait as I must define a TimeOut. This script will wait for the jquery to finish its job even if it takes 10 minutes. I have tried this in a demo website where I preconfigured a hard coded wait of 7 minutes. And It worked for me.

//Wait for JQuery Load
public static void waitForJQueryLoad() {
    //Wait for jQuery to load
    ExpectedCondition<Boolean> jQueryLoad = driver -> ((Long) ((JavascriptExecutor) jsWaitDriver)
            .executeScript("return jQuery.active") == 0);

    //Get JQuery is Ready
    boolean jqueryReady = (Boolean) jsExec.executeScript("return jQuery.active==0");

    //Wait JQuery until it is Ready!
    if(!jqueryReady) {
        System.out.println("JQuery is NOT Ready!");
        //Wait for jQuery to load
        jsWait.until(jQueryLoad);
    } else {
        System.out.println("JQuery is Ready!");
    }
}

If it's something other than JQuery. Just take a look at the sample provided in that web site(https://www.swtestacademy.com/selenium-wait-javascript-angular-ajax/). You may end up with Angular, JQuery and XHR request solutions also.

answered on Stack Overflow Aug 24, 2018 by Canberk Akduygu

User contributions licensed under CC BY-SA 3.0