Verify element is enabled in Selenium WebDriver

In this How to verify element is enabled in Selenium WebDriver post you will learn how we can verify particular elements is enabled,During selenium web driver testing or test cases creation,most of the time you need to check targeted elements,whether particular elements are enable or not on web application before doing any actions on page.

Verify element is enabled in Selenium WebDriver

In order to overcome this problem Selenium WebDriver providing in built method isEnabled() to verify the elements disable or enable status of web applications.Suppose while working on my new web applications ,we have to verify while creating new customers but here first all the fields are disabled when you enter mobile number and click on Search button then only remaining elements will enable to perform action/create new customers.Elements disable means before performing any action need to enable elements to perform new actions as above example.

ALSO READ  Run Selenium Script using runnable JAR


Run Selenium scripts using Command Line
Run Selenium Scripts using Runnable JAR
TOP Selenium Interview Questions asked in MNC
How to Send attachments in Jenkins emails
Selenium XPATh tutorial step by step
Session ID is null using webdriver after calling quit
How to send extent reports in email with screenshots
Write Test Cases PASS or FAIL using Selenium


isEnabled() – is a Selenium WebDriver method which is developed in Web Element class in order to verify if particular element is enabled or not,in case it is not enabled it will return false or Fail.


WebElement Save = driver.findElement(“save_btn”));
boolean save_button=Save.isEnabled();You can use isEnabled() Selenium WebDriver method in IF condition to check the condition to return ture in case it is verifying the condition of element is enabled or not.We will see isEnabled method with example and below example will give you brief details about how to use isEnabled() method in a method to check element id enabled or not.

ALSO READ  How To write Test Case is PASS or FAIL using Selenium

As I am using TestNG framework to create the test cases in Selenium WebDriver ,Please follow below steps and code to verify element is enabled or not.

1.Create Class
2.Add TestNG library
3.Create Method with any name
4.Save elements in WebElements
5.Use if condition to verify Whether element is enabled or not.

public void verify_CustElements() throws InterruptedException{

//Store all customer elements in WebElments
WebElement FirstName = driver.findElement(“first_name”));
WebElement Email = driver.findElement(“email”));
WebElement Save = driver.findElement(“save_btn”));

//Verify Mobile No field is in disable mode
System.out.println(“Mobile No field is in Enabled mode”);
System.out.println(“Mobile No field is in disabled mode,Test Case is FAIL”);

//Verify SAVE button is in disable mode

System.out.println(“Save button is in enable mode ,Test Case is PASS”);

System.out.println(“Save button is in disable mode ,Test Case is FAIL”);

System.out.println(“Email field is in enabled mode ,Test Case is PASS”);
System.out.println(“Email field is in disabled mode ,Test Case is FAIL”);

As per above example,it will check the status of First name and save button text box and print the message in Eclipse console based on element is enabled or disabled.In case you like, it is helpful ,please share it and please provide valuable comments on this topic and please provide do you have any questions.

ALSO READ  Run Selenium Webdriver Scripts using Command Line

Rajesh K