Element is not clickable at point SeleniumWebdriverException

This issue comes only when working with chrome driver as the chrome browsers uses point location. When the element position is not fixed and we are trying to do some action on that particular element will result an error as 'selenium.common.exceptions.WebDriverException - Element is not clickable at point (xx, xx). Other element would receive the click'.

This happens when the element is loaded into the DOM, but the position is not fixed on the UI. There can be some other divs or images or ads that are not loaded completely. And ChromeDriver always tries to click the middle of the element.

There are work around that worked to resolve the issue. But to make sure the best and simple solution is to find out the exact reason to fix the problem. We need to figure out which part of the div/image is taking time to load. Before clicking on an element we need to make sure the element is present in the DOM, visible in the UI and the last is Position is fixed. When the element position is fixed the problem is solved. If you want to check that, try Thread.sleep or verify in debug mode.

But using Thread.sleep is not at all a good idea. Instead we should go for WebDriverWait ExpectedConditions.

There are many Conditions that we can use withing Webdriver tests.

1. visibilityOf(WebElement element) : An expectation for checking that an element, known to be present on the DOM of a page, is visible.
2. visibilityOfElementLocated(By locator) : An expectation for checking that an element is present on the DOM of a page and visible.

In the above two conditions we are waiting for an element to be present on the DOM of a page and also visible. These works fine only when the element is loaded completely.

Even though the element is loaded and visible. For chrome driver the position of the element is also important. Remember this will work perfectly on Firefox driver.

Then How to solve this problem in Chrome????? . You can also check the number of comments and discussions on Chrome Element is not clickable issue

The below are the different work around that worked for people who also faced the same problem.

1. This is a simple solution that worked for many people. Try to maximize the browser when you are working with resolutions greater than 1024x768.

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

2. The other solution which also worked for few users using Actions Class

WebElement element = driver.findElement(By("element"));
Actions action = new Actions(driver);
action.moveToElement(element).click().perform();

3. It worked for some using JavaScriptExecutor. Make sure to import org.openqa.selenium.JavascriptExecutor;

JavascriptExecutor js = (JavascriptExecutor)driver;
 // if the element is on top.
js.executeScript("scroll(250, 0)");

// if the element is on bottom.
js.executeScript("scroll(0, 250)");

4. You can also try the below using X or Y position

        WebElement element = driver.findElement(By.id(""));
        JavascriptExecutor js =(JavascriptExecutor)driver;
        js.executeScript("window.scrollTo(0,"element.getLocation().x+")");
        element.click();

Or

        WebElement element = driver.findElement(By.id(""));
        JavascriptExecutor js =(JavascriptExecutor)driver;
        js.executeScript("window.scrollTo(0,"element.getLocation().y+")");
        element.click();
Selenium Tutorials: 

Comments

Hello your article has helped me a lot. I would like to know is there any way to do the internationalization in selenium?

Hi there,

could you please try once below code.

FirefoxProfile profile = new FirefoxProfile();
profile.setPreference("intl.accept_languages","sl"); // Here 'sl' means one type of language
driver = new FirefoxDriver(profile);

Hi, thx for help) By one littele mistake, 2 same snippets of code
WebElement element = driver.findElement(By.id(""));
JavascriptExecutor js =(JavascriptExecutor)driver;
js.executeScript("window.scrollTo(0,"element.getLocation().x+")"); // <-- here must be "x"
element.click();

Your this topic is very useful to me, i was looking for the same topic since a long time. Thanks again

Hi,

driver.maximize() did work for my case to avoid "element not clickable exception". Thanks a ton.

This worked for me too...inspite of trying actions, visibility and what not.

Firefox has same error. Not only chrome.

Can some one help me to resolve this issue in flipkart site. Go to www.flipkart.com --> ELECTRONICS --> Motorola --> Click Buy by using Selenium code. Getting the "element not clickable exception" I am facing this exception in Chrome, Firefox, IE. I think this is not an issue with browser.

WebElement element = driver.findElement(By.id(""));
JavascriptExecutor js =(JavascriptExecutor)driver;
js.executeScript("window.scrollTo(0,"element.getLocation().x+")"); // <-- here must be "x"
element.click();

The same code does not work once it is placed in "IF" Statement. It scrolls too much in the bottom for the element to be visible. Can you suggest a workaround for this?

I also faced this issue.
I downgraded the selenium stand alone jar to 2.46
It is working fine.

Add new comment

CAPTCHA
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.