Launch browser and navigate to
https://examples.wufoo.com/forms/allow-other-choices-on-multiple-choice-fields/
find total number of radio button
and click on radio buttons if its matched with "Stir Fry"
https://examples.wufoo.com/forms/allow-other-choices-on-multiple-choice-fields/
find total number of radio button
and click on radio buttons if its matched with "Stir Fry"
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.session3; | |
import java.util.List; | |
import org.openqa.selenium.By; | |
import org.openqa.selenium.WebDriver; | |
import org.openqa.selenium.WebElement; | |
import org.openqa.selenium.chrome.ChromeDriver; | |
public class RadioButton { | |
public static void main(String[] args) throws InterruptedException { | |
// TODO Auto-generated method stub | |
System.setProperty("webdriver.chrome.driver","youtpath/chromedriver"); | |
WebDriver driver = new ChromeDriver(); | |
driver.get("https://examples.wufoo.com/forms/allow-other-choices-on-multiple-choice-fields/"); | |
Thread.sleep(6000); | |
//driver.findElement(By.xpath("//input[@name='not_checked']")).click(); | |
// click on on all check box's... | |
// gt dynamic counts of check box... | |
List rd = driver.findElements(By.xpath("//input[@type='radio']")); | |
System.out.println(rd.size()); | |
for (int i=0;i | |
// get the attribute | |
String val = rd.get(i).getAttribute("value"); | |
System.out.println(val); | |
String exp="Stir Fry"; | |
if(val.equals(exp)){ | |
System.out.println("am in condition will click on stir fry-->"); | |
rd.get(i).click(); | |
break; | |
} | |
} | |
} | |
} |