Element not clickable at point Selenium Webdriver


Element not clickable at point (x, y)


This issue normally occurs if the target element is not clickable, which means that the element is not in the state of user interaction. This is due to the following reason
A.) Element is in list and is currently not in the view-able area of the browser

How To Fix

  1. (Case A)Scroll the page so the element comes in the viewable area of the browser
    for example:

    // Get the element
    WebElement targetElement = driver.findElement(By.id("itemid"));
    // Create the JavascriptExecutor object
    JavascriptExecutor jse = (JavascriptExecutor)driver;
    // Scroll down the page to the element with JavaScript
    jse.executeScript("window.scrollTo(0,'+elementToClick.getLocation().y+')");// Click on the element
  2. (General Case) This method doesn’t care about the current state of the target element. No matter if the element is at the bottom of the page and requires scroll to access it.
    So this method is a bit hackish since from the user point of view you cannot click(or interact with) an element if the element is present at the bottom of the page and requires some scrolling.

    In this method we use JavaScript to perform the click. This method will succeed as long as the element is present in the page.

    Here is how to do this:

    //Get the element
    WebElement we = driver.findElement(By.id("elementid"));
    // Create the JSExecutor object
    JavascriptExecutor executor = (JavascriptExecutor)driver;
    // Perform the click with javascript
    executor.executeScript("arguments[0].click();", we);

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s