element is not clickable at point Selenium Webdriver Solved!


Have you been using a lot of selenium webdriver then this isnt something common but you see that the error states:

element is not clickable at point(x,y)
Seriously?? And then you try everything :
  • This happens only on chrome so it works on ie and firefox 
  • ChromeDriver always clicks the middle of the element
  • The reason Chrome driver doesn't calculate the correct screen location of link.
Solution:
// Find an element and define it
WebElement elementToClick = driver.findElement(By.xpath("some xpath"));
// Scroll the browser to the element's Y position
((JavascriptExecutor) driver).executeScript("window.scrollTo(0,"+elementToClick.getLocation().y+")");
// Click the element
elementToClick.click();


Note: If the Y position doesnt work the X will work for sure

((JavascriptExecutor) driver).executeScript("window.scrollTo(0,"+elementToClick.getLocation().x+")");


Update
If the solution doesn't work or even if it does Download the latest chrome driver and bingo!! You will see it work for sure

Comments

  1. Anonymous21/5/15

    A workaround I came up with:
    protected void ClickElement(IWebElement element)
    {
    var builder = new Actions(driver);
    builder
    .MoveToElement(element)
    .Click(element)
    .Build()
    .Perform();
    }

    ReplyDelete
    Replies
    1. I used it this one but getting the same issue.And not for chrome its getting for firefox.

      Delete
    2. I used it this one but getting the same issue.And not for chrome its getting for firefox.

      Delete
  2. Awesome Post!! Found it after 2 days of googling. Was an absolute life saver for me.

    ReplyDelete
  3. Anonymous6/3/17

    I am beginner to selenium what is this exception? org.openqa.selenium.WebDriverException: Element is not clickable.

    ReplyDelete

Post a Comment

Popular posts from this blog

Software Testing @ Microsoft

Trim / Remove spaces in Xpath?