
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Selenium Exception: Element is Not Clickable at Point (X, Y)
We may encounter the Selenium Exception Error - Element is not clickable at point(x,y). Other element would receive the click while working Selenium webdriver.
This is normally seen while executing Selenium tests from the Chrome browser and not with other browsers like IE and Firefox. This happens because the Chrome browser could not compute the correct location of a webelement.
Besides, in the Chrome browser, an element is clicked in its middle position. This exception can also be encountered owing to synchronization issues happening between the application and Selenium.
There exists some solutions to fix this issue as listed below −
We should ensure that we are using the latest version of the chromedriver and it is compatible with the Chrome browser version we have in our local system.
Obtain the coordinates of a webelement and then perform click on it using methods in Actions class.
Syntax
WebElement elm = driver.findElement(By.tagName("input")); //instance of Point class Point location = elm.getLocation(); //get x, y coordinates int m = location.getX(); int n = location.getY(); //instance of Actions class Actions a = new Actions(driver); a.moveToElement(elm,m,n).click().build().perform();
Obtain the coordinates of a webelement and click it using JavaScript Executor.
Syntax to get x-coordinate −
WebElement l = driver.findElement(By.tagName("input")); JavascriptExecutor j =(JavascriptExecutor)driver; j.executeScript( "window.scrollTo(0,"l.getLocation().x+")"); l.click();
Syntax to get y-coordinate −
WebElement l = driver.findElement(By.tagName("input")); JavascriptExecutor j =(JavascriptExecutor)driver; "window.scrollTo(0,"l.getLocation().y+")"); l.click();