We use cookies to analyze site traffic and show personalized ads. You can accept all cookies or decline personalized advertising.
Learn more in our Privacy Policy.
Understand how Selenium checks if an element is really clickable before performing actions.
Before Selenium calls click() or sendKeys(), it doesn’t just “trust” the DOM. It tries to behave like a real user and asks: Can a human actually interact with this element right now?
click(), sendKeys(), etc.) include built-in safety checks.Methods like click(), sendKeys(), and clear() validate that the element is interactable:
The Actions API allows moving the mouse to coordinates and clicking, but it does not perform the same level of checks.
display: none or visibility: hidden and must have a non-zero size.enabled. Disabled elements are present in the DOM but not interactive.Current State: normal
Interact with the state buttons to see how the "Click Me!" button behaves. Use Selenium to try clicking it in different states!
1234567891011121314151617181920212223WebElement normalStateButton = driver.findElement(
By.xpath("//button[contains(text(),'Normal (Interactable)')]"));
normalStateButton.click();
WebElement testButton = driver.findElement(By.id("test-button"));
testButton.click();
WebElement hiddenStateButton = driver.findElement(
By.xpath("//button[contains(text(),'Hidden')]"));
hiddenStateButton.click();
WebElement disabledStateButton = driver.findElement(
By.xpath("//button[contains(text(),'Disabled')]"));
disabledStateButton.click();
WebElement coveredStateButton = driver.findElement(
By.xpath("//button[contains(text(),'Covered')]"));
coveredStateButton.click();
testButton = driver.findElement(By.id("test-button"));
testButton.click();
driver.quit();When you see "element not interactable" or "element click intercepted", read them as "a real user couldn’t click this right now", not as "Selenium is broken".
Use simple checks like isDisplayed() and isEnabled() before calling click() on tricky elements.
Prefer stable, readable locators (id, clear xpath) when working with dynamic states to make debugging easier.