How to check if element is disabled in Selenium Java

isEnabled()

isEnabled() method in Selenium webdriver will verify and return true if the specified element is enabled. otherwise, it will return false.

Syntax:

 

boolean FirstName= driver.findElement(By.id(“fname”)).isEnabled();

System.out.print(FirstName);

Selenium Code :

Here Selenium Code to verify if the element is active or Deactive is given.

import org.openqa.selenium.By;

import org.openqa.selenium.WebDriver;

import org.openqa.selenium.chrome.ChromeDriver;

public class Login {

public static void main(String[] args) {

// TODO Auto-generated method stub

System.setProperty(“webdriver.chrome.driver”, “C:\\Software Program\\chromedriver.exe”);

WebDriver driver=new ChromeDriver();

driver.get(“https://www.facebook.com”);

//To verify that Element is Enabled or not

Boolean nn =driver.findElement(By.xpath(“//input[ @type=\”text\”]”)).isEnabled();

if(nn) {

System.out.println(“Element is Present”);

}

else {

System.out.println(” Element is not Present”);

}

}

}

How To Verify Element is Enabled or Disabled in Selenium
Verify Element is enabled or Disabled in Selenium

Also Read

How to enter Text in text box using Selenium 

By Admin

Welcome to Automation QA, your ultimate destination for comprehensive tutorials on automation across various domains. Whether you're a seasoned QA professional looking to enhance your skills or a newcomer eager to delve into the world of automation testing, our platform has something for everyone.

Leave a Reply

Your email address will not be published. Required fields are marked *