How to resolve exception - "element click intercepted ,Other element would receive the click"?



  • Here is my script -

    next=WDS.browser.findElement(pkg.By.xpath("//button[contains(@class,'btn btn-sm btn-light border ml-3')]"))
    

    while(next.isEnabled()==true)
    {
    //java.lang.Thread.sleep(4000);

                var wait19 =new org.openqa.selenium.support.ui.WebDriverWait(WDS.browser, 9000)
        wait19.until(org.openqa.selenium.support.ui.ExpectedConditions.elementToBeClickable(pkg.By.xpath("//button[contains(@class,'btn btn-sm btn-light border ml-3')]"))).click()
                
                 
                
    next=WDS.browser.findElement(pkg.By.xpath("//button[contains(@class,'btn btn-sm btn-light border ml-3')]"))
    

    //WDS.log.info(WDS.browser.getPageSource())
    if (!next.isEnabled()) {
    WDS.log.info('Next button disabled')
    break
    }
    }

    In my application, I need to visit total 300 pages and calculate time taken to traverse from first page to last.

    But, when click on next button, it throws exception:

    ERROR c.g.j.p.w.s.WebDriverSampler: element click intercepted: Element is not clickable at point (226, 567). Other element would receive the click:

    ...

    How do I resolve it?



  • The error means that the button you're trying to click is being "covered" by some form of animation https://www.w3schools.com/howto/howto_css_loader.asp most probably showing that the data is loaded

    You need to use https://www.selenium.dev/documentation/webdriver/waits/#explicit-wait to wait until this animation loader becomes invisible so you would be able to click the button.

    Put this line before the line which fails:

    wait19.until(org.openqa.selenium.support.ui.ExpectedConditions.invisibilityOfElementLocated(pkg.By.xpath("//div[contains(@class,'ng-animating')]")))
    

    and it should resolve your issue.

    More information: https://www.blazemeter.com/blog/webdriver-sampler-your-top-ten-questions-answered


Log in to reply
 


Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2