Getting this error: "Element is not clickable at point"

SeleniumAutomation TestingTesting Tools

We can get the error - Element is not clickable at point while working with Selenium webdriver. This normally happens in chromedriver since the Chrome browser utilises point location to identify an element.

When the position of an element is dynamic and we want to click on that element, then this error is thrown. The cause of this error is if an element is available in DOM, but its position is dynamic in the front end.

Some of the ways to fix this issue are listed below −

  • Usage of explicit wait. We can use wait for the expected condition - visibilityOf. The webdriver shall wait for an element available in DOM to be visible.

  • Usage of explicit wait. We can use wait for the expected condition - visibilityOfElementLocated. The webdriver shall wait for an element to be available in DOM and be visible.

  • Maximize the browser size.

Syntax

driver.manage().window().maximize();
  • Usage of Actions action.

Syntax

WebElement m = driver.findElement(By.id("txt-loc"));
Actions a = new Actions(driver);
a.moveToElement(m).click().perform();
  • Usage of JavaScript Executor.

Syntax to obtain location on the x axis −

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

Syntax to obtain location on the y axis −

WebElement n = driver.findElement(By.id("txt"));
JavascriptExecutor j =(JavascriptExecutor)driver;
j.executeScript(
   "window.scrollTo(0,"n.getLocation().y+")");
   m.click();
raja
Published on 29-Jun-2021 08:02:27
Advertisements