Webdriver Scripts : How to check whether button is enabled or disabled in Selenium Web driver


package selenium_examples;



import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;



public class spicejet {

public static void main(String[] args) {


WebDriver driver = new FirefoxDriver();
driver.get("http://www.google.com/");

if(driver.findElement(By.id("gbqfba")).isEnabled())
{
System.out.println("Button is Enabled");
}
else
{
System.out.println("Button is Disabled");
}


}
  }


Output:-

Button is Enabled


Selenium webdriver script to check whether textbox is enabled or disabled

package selenium_examples;



import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;



public class spicejet {

public static void main(String[] args) {


WebDriver driver = new FirefoxDriver();
driver.get("http://www.google.com/");

if(driver.findElement(By.id("gbqfq")).isEnabled())
{
System.out.println("Textbox is Enabled");
}
else
{
System.out.println("Textbox is Disabled");
}


}
  }


Output:-

Textbox is Enabled



No comments:

Related Posts Plugin for WordPress, Blogger...