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.
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();
4. You can also try the below using X or Y position
- ‹ Passing data to DataProvider from Excel sheet
- Extract PDF text And Verify Text Present in PDF using WebDriver ›