Saturday, 18 February 2012

working with radio buttons for selenium automation testing


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 dadabhagwan_LearnSeleniumWithJasmine {

public static void main(String[] args) throws InterruptedException {

WebDriver myDriver = new FirefoxDriver();
myDriver.get("http://egroup.dadabhagwan.org/Register.aspx");


// radio button group of "Gnan Taken"
List radio_Gnan_Taken = myDriver.findElements(By.name("ctl00$cpMaster$grpGyan"));

for(int i=0;i
System.out.print(radio_Gnan_Taken.get(i).getAttribute("Value")+"*************");
System.out.println(radio_Gnan_Taken.get(i).getAttribute("checked"));
}

radio_Gnan_Taken.get(0).click();

for(int i=0;i
System.out.print(radio_Gnan_Taken.get(i).getAttribute("Value")+"*************");
System.out.println(radio_Gnan_Taken.get(i).getAttribute("checked"));
}

// radio button group of "Dadavani Magazine Member"
radio_Gnan_Taken = myDriver.findElements(By.name("ctl00$cpMaster$grpDadawani"));

for(int i=0;i
System.out.print(radio_Gnan_Taken.get(i).getAttribute("Value")+"*************");
System.out.println(radio_Gnan_Taken.get(i).getAttribute("checked"));
}

radio_Gnan_Taken.get(0).click();

for(int i=0;i
System.out.print(radio_Gnan_Taken.get(i).getAttribute("Value")+"*************");
System.out.println(radio_Gnan_Taken.get(i).getAttribute("checked"));
}


// radio button group of "Preferred format for email"
radio_Gnan_Taken = myDriver.findElements(By.name("ctl00$cpMaster$grpEformat"));

for(int i=0; i
System.out.print(radio_Gnan_Taken.get(i).getAttribute("Value")+"*************");
System.out.println(radio_Gnan_Taken.get(i).getAttribute("checked"));
}


radio_Gnan_Taken.get(0).click();

for(int i=0;i
System.out.print(radio_Gnan_Taken.get(i).getAttribute("Value")+"*************");
System.out.println(radio_Gnan_Taken.get(i).getAttribute("checked"));
}


}

}