import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.By;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized.Parameters;
import org.junit.runners.Parameterized;
import static org.junit.Assert.*;
import java.util.Collection;
@RunWith(value = Parameterized.class)
private static WebDriver driver;
private static StringBuffer verificationErrors = new
private String bmiCategory;
public static Collection testData() {
{"160","45","17.6","Underweight"},
{"168","70","24.8","Normal"},
{"181","89","27.2","Overweight"},
{"178","100","31.6","Obesity"}
public SimpleDDT(String height, String weight, String bmi, String bmiCategory)
this.bmiCategory = bmiCategory;
public void testBMICalculator() throws Exception {
//Get the Height element and set the value using parameterised
WebElement heightField = driver.findElement(By.name("heightCMS"));
heightField.sendKeys(height);
//Get the Weight element and set the value using parameterised
WebElement weightField = driver.findElement(By.name("weightKg"));
weightField.sendKeys(weight);
//Click on Calculate Button
WebElement calculateButton = driver.findElement(By.id("Calculate"));
//Get the Bmi element and verify its value using parameterised
WebElement bmiLabel = driver.findElement(By.name("bmi"));
assertEquals(bmi, bmiLabel.getAttribute("value"));
//Get the Bmi Category element and verify its value using
//parameterised bmiCategory variable
WebElement bmiCategoryLabel = driver.findElement(By.name("bmi_category"));
assertEquals(bmiCategory,bmiCategoryLabel.
//Capture and append Exceptions/Errors
verificationErrors.append(e.toString());
System.err.println("Assertion Fail "+ verificationErrors.