I am trying to find the button whether it is Read Only or Enabled (Clickable) in the page. After doing some action. I need to check this in if else condition so kindly help me to find the solution.
below are my html code of the button
<div id="agent_delete"
class="btn btn_own"
ng-confirm-click="Are you sure you want to delete selected Agent(s)?"
confirm-click-title="Delete Agent"
confirmed-click="delete()"
ng-disabled="!ctrlService.canDelete || gridApi.selection.getSelectedRows().length == 0"
disabled="disabled">
<div id="agent_delete"
class="btn btn_own"
ng-confirm-click="Are you sure you want to delete selected Agent(s)?"
confirm-click-title="Delete Agent"
confirmed-click="delete()"
ng-disabled="!ctrlService.canDelete || gridApi.selection.getSelectedRows().length == 0">
You have to use isEnabled(); method.
if(driver.findElement(By.id("agent_delete")).isEnabled()){
//button is enabled
}
else{
//button is not enabled
}
You could check the disabled attribute with getAttribute:
WebElement element = driver.findElement(By.id("agent_delete"));
if("disabled".equals(element.getAttribute("disabled"))) {
// disabled
} else {
// enabled
}
Or with a CSS selector with a single call:
if(driver.findElements(By.cssSelector("#agent_delete[disabled='disabled']")).size > 0) {
// disabled
} else {
// enabled
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With