ElementClickInterceptedException: Element not clickable

This error might have occurred when you are trying to click a button is radio button or checkbox or just a click operation.

Exception in thread "main" org.openqa.selenium.ElementClickInterceptedException: 
element click intercepted: 
Element <input value="Google Search" aria-label="Google Search" name="btnK" type="submit">
 is not clickable at point (596, 368). 
Other element would receive the click: <span>...</span>

This error occurs when the target element that you want to click is overlaid by some other element in the web page.

For example, when you have an element below the dropdown/ Submenu; then you might have faced this kind of error. Sometimes some model pop-ups also can cause this kind of overlay on the element, so when you try to click such kind of element then you will receive an element not clickable exception.

In the below example, we are going to click on the Google search button after entering the term Facebook on the search bar. In the below image you can see, the auto suggestions are overlaid on the Google search button.

element-not-clickable-selenium

Ways that do not solve the problem:
  • Clicking the element again
  • Waiting using sleep
  • Waiting till element becomes clickable
Solution:

We have to trigger the click operation using the JavaScript executor.

public static void main(String[] args) throws Exception {
	System.setProperty("webdriver.chrome.driver", "D:\\PATH\\chromedriver.exe");
	WebDriver driver = new ChromeDriver();
	driver.manage().window().maximize();
	driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
	driver.get("https://google.com");
	
	driver.findElement(By.name("q")).sendKeys("facebook");
	WebElement searchButton = driver.findElement(By.xpath("(//input[@value='Google Search'])[2]"));
	JavascriptExecutor js = (JavascriptExecutor)driver;
	js.executeScript("arguments[0].click()", searchButton);	  
}
About Author :

I am Pavankumar, Having 8.5 years of experience currently working in Video/Live Analytics project.

Comment / Suggestion Section
Point our Mistakes and Post Your Suggestions