OpenQA.Selenium.WebDriverException: Element is not clickable. Other element would receive click.

Problem

I am using Selenium to automate navigating a website. I’m trying to click a button:

var btnSave = driver.FindElement(By.Id("btnSave")); btnSave.Click();

When I try to click the button it’s throwing the following exception:

OpenQA.Selenium.WebDriverException: Element is not clickable. Other element would receive click.

The reason this is happening is because Selenium is trying to click the button by its coordinates, and there is something overlapping with the button.

Solution

Use JavaScriptExecutor.ExecuteScript to perform the click instead.

using OpenQA.Selenium; using OpenQA.Selenium.Chrome; namespace SeleniumTest { class Program { static void Main(string[] args) { IWebDriver driver = new ChromeDriver(); IJavaScriptExecutor javaScriptExecutor = (IJavaScriptExecutor)driver; driver.Navigate().GoToUrl("Some URL that I'm not showing here"); var btnSave = driver.FindElement(By.Id("btnSave")); javaScriptExecutor.ExecuteScript("arguments[0].click();", btnSave); } } }

Leave a Comment