I\'m new to Selenium
and need to check if element is clickable in Selenium
Java
, since element.click()
passes both on
From the source code you will be able to view that, ExpectedConditions.elementToBeClickable()
, it will judge the element visible and enabled, so you can use isEnabled()
together with isDisplayed()
. Following is the source code.
public static ExpectedCondition<WebElement> elementToBeClickable(final WebElement element) {
return new ExpectedCondition() {
public WebElement apply(WebDriver driver) {
WebElement visibleElement = (WebElement) ExpectedConditions.visibilityOf(element).apply(driver);
try {
return visibleElement != null && visibleElement.isEnabled() ? visibleElement : null;
} catch (StaleElementReferenceException arg3) {
return null;
}
}
public String toString() {
return "element to be clickable: " + element;
}
};
}