How to Handle Radio Button in Selenium Webdriver using Java

         Handling Radio Button in selenium 

How to handle radio button in Selenium webdriver ?
In this tutorial we are going to learn how to automate radio button in selenium webdriver.

  • How to select radio button in selenium webdriver using java ?
Click() - By using the click method we select a radio button in selenium webdriver.

Selenium Code 
// To select Radio button
driver.findElement(By.xpath("//label[@for='yesRadio']")).click();
System.out.println("Radio Button selected successfully ");

  • How to Verify radio button is selected by default in selenium using java?
isSelected()- In selenium webdriver to check whether the radio button is selected or not we use isSelected () method .

Selenium Code 
//How to check radio button is selected or not by default
WebElement Wb=driver.findElement(By.xpath("//label[@for='yesRadio']"));
boolean ar=Wb.isSelected();
System.out.println(ar);
if(ar==false)
Wb.click();
System.out.println("Radio Button selected successfully ");

  • How to verify radio button is enable or not in selenium using java?
isEnable()- To verify a radio button is in disable mode or enable mode we use a predefine method known as isEnable method

Selenium Code
//how to check radio button is enabled in selenium
WebElement Wb=driver.findElement(By.id("noRadio"));
boolean rs =Wb.isEnabled();
//System.out.println("Radio button is not enable");
if(rs==true)
{
Wb.click();
}
  • How to verify that radio button is displayed or not on webpage in selenium webdriver  ?
isDisplayed ()- To verify that a radio button is displayed on webpage or not we use predefine method isDisplayed.
Selenium Code 
/how to verify radio button is displayed on webpage or not
WebElement Wb=driver.findElement(By.xpath("//label[@for='yesRadio']"));
        boolean ar=Wb.isDisplayed();
        if(ar==true) {
         Wb.click();
        }

Hope!!! Above tutorial of handling radio button in selenium using java helpful for you ....
Team , 
QA acharya 

Tags : Handling radio button in selenium , radio button in selenium , how to select radio button in selenium 

how to handle Radio button in selenium 


Post a Comment

0 Comments