How to deal with Radio buttons using Selenium Webdriver? - TestingQ.com

-->Exclusive Portal for Testing Jobs

How to deal with Radio buttons using Selenium Webdriver?

import java.util.List;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;

public class TestRadioButtons {

    public static void main(String[] args) {
        WebDriver myTestDriver = new FirefoxDriver();
        myTestDriver.get("http://www.htmlcodetutorial.com/forms/_INPUT_TYPE_RADIO.html");

        List<WebElement> RadioGroup1 = myTestDriver.findElements(By.name("pizzasize"));

        for(int i =0; i < RadioGroup1.size() ; i++ ){
            System.out.println(RadioGroup1.get(i).isSelected());
        }

        RadioGroup1.get(2).click();

        for(int i =0; i < RadioGroup1.size() ; i++ ){
            System.out.println(RadioGroup1.get(i).isSelected());
        }
    }
}



To receive daily posted JOBS & Interview Questions
Just enter your email address below and click 'Submit'
Enter your email address:

Make sure to activate your subscription by clicking on the activation link sent to your email