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());
}
}
}
Follow @TestingQ
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());
}
}
}