Debugging "Element is not clickable at point" error

Viewed 634938

I see this only in Chrome.

The full error message reads:

"org.openqa.selenium.WebDriverException: Element is not clickable at point (411, 675). Other element would receive the click: ..."

The element that 'would receive the click' is to the side of the element in question, not on top of it and not overlapping it, not moving around the page.

I have tried adding an offset, but that does not work either. The item is on the displayed window without any need for scrolling.

52 Answers

You need to use focus or scroll on that element. You also might have to use explict wait.

WebElement firstbutton= driver.findElement(By.xpath("Your Element"));
Actions actions = new Actions(driver);
actions.moveToElement(element);
actions.perform();

OR

The element is not clickable because of a Spinner/Overlay on top of it:

By loadingImage = By.id("loading image ID");
WebDriverWait wait = new WebDriverWait(driver, timeOutInSeconds);
wait.until(ExpectedConditions.invisibilityOfElementLocated(loadingImage));

OR

Point p= element.getLocation();
Actions actions = new Actions(driver);
actions.moveToElement(element).movebyoffset(p.x,p.y).click().perform();

OR

If still not work use JavascriptExecutor

JavascriptExecutor executor = (JavascriptExecutor)driver;
executor.executeScript("arguments[0].click();", firstbutton);

I, too, wrestled with this problem. Code works fine in FF, fails on Chrome. What I was trying to do was to click a tickbox - if it wasn't in view, I'd scroll to view and then click. Even scrolling into view works in Chrome, only the bottom few pixels of the tickbox wasn't visible so webdriver refused to click on it.

My workaround is this:

WebElement element = _sectorPopup.findElement(...);

((Locatable) element).getCoordinates().inViewPort();
try {
    element.click();
} catch (Exception e) {
    new Actions(getWebDriver()).sendKeys(Keys.PAGE_DOWN).perform();
    element.click();
}

Chrome also has issues with sendKeys, using Actions is sometimes necessary. Obviously, you need to know which direction and how much you need to go so your mileage may vary. But I prefer this to the javascript hack, so I'm posting it here in case someone else will find it useful.

When using Protractor this helped me:

var elm = element(by.css('.your-css-class'));
browser.executeScript("arguments[0].scrollIntoView();", elm.getWebElement());
elm.click();

Today I got the same kind of issue. You don't believe me if i say how i solved the issue.

By maximizing the browser size

Yes, it is a pointer issue that means the size of the browser. For that, you just need to maximize the window size manually or through the code.

The reason for this error is that the element that you are trying to click is not in the viewport (region seen by the user) of the browser. So the way to overcome this is by scrolling to the desired element first and then performing the click.

Javascript:

async scrollTo (webElement) {
    await this.driver.executeScript('arguments[0].scrollIntoView(true)', webElement)
    await this.driver.executeScript('window.scrollBy(0,-150)')
}

Java:

public void scrollTo (WebElement e) {
    JavascriptExecutor js = (JavascriptExecutor) driver; 
    js.executeAsyncScript('arguments[0].scrollIntoView(true)', e)
    js.executeAsyncScript('window.scrollBy(0,-150)')
}

Try to maximize the browser when you are working with resolutions greater than 1024x768.

driver.manage().window().maximize();

I was also stuck for two days because of the same reason, actually Scrolling will make it work, because may be the data couldn't load properly, which may cause the same error again and again.

What I did is, I scroll down randomly, once with (0,-500), then (0,400), then (0.-600), you may give these scroll value according to your use. Just scroll it where you have the content to click.

driver.execute_script("scrollBy(0,-500);")
sleep(5)

driver.execute_script("scrollBy(0,400);")
sleep(5)

driver.execute_script("scrollBy(0,-600);")
sleep(5)

It really worked :)

If you are having this issue with a modal (pop-up), note that it may be that another element with the same properties exists underneath the current top level modal. This caught me out, just increase the specificity of your selector to reduce the scope to that of the modal you are trying to click only.

I was having this exact issue when clicking a button within an Angular Material menu. Whenever I clicked a button inside a menu, the .cdk-overlay-pane would receive the click. The solution is to increase the z-index of buttons inside the menu.

.cdk-overlay-pane button {
  z-index: 1001;
}

There may be lots of factor which will throw this error. Firstly, the dom may be changed after selenium webdriver captured the element or all the java scripts used in elements is not loaded successfully before capturing the element. To fix this we need to use javascript wait or ajax wait like as follow.

wait = new WebDriverWait(driver, 30);
wait.until((ExpectedCondition<Boolean>) wd -> ((JavascriptExecutor) wd).executeScript("return document.readyState").equals("complete"));
        e_driver = new EventFiringWebDriver(driver);

Secondly, most of the engineers of companies providing software qa services try using java script executor for the click action.

If this also doesn't work then perform action using Actions class.

In my case, it worked in Firefox but failed in Chrome. In Chrome, it got fixed after updating Chrome driver version to the latest.

In Rselenium, this happened with code successfully used many times when a link was positioned at the top window border. Simple solution was to use sendKeysToElement() as follows.

if (unlist(webElem$isElementDisplayed())) {
    webElem$sendKeysToElement(list(key = "up_arrow"))  # Add "up arrow"..
    webElem$clickElement()  # ... before $clickElement
WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(15));
wait.Until(SeleniumExtras.WaitHelpers.ExpectedConditions.ElementToBeClickable(By.<Id or anything>));

Hope this helps.

This can also happen if you are trying to click on a input or button that is disabled, in that case there nothing overlapping the element, but it's not clickable.

Debugging "Element is not clickable at point" error

To handle this error scroll down using this code.

browser.execute_script("window.scrollTo(0, 300);")
Related