package seleniumTestNG;
import org.testng.annotations.Test;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.annotations.BeforeTest;
public class TestNG_J_DataProvider {
WebDriver driver;
public String str;
@org.testng.annotations.DataProvider(name="datainput")
public String[][] login()
{
return new String[][]{
{"Validuser","InValidPassword"},
{"ValidUsername@gmail.com","ValidPassword"},
{"InvalidUser","InvalidPassword"}
};
}
@Test (dataProvider="datainput")
public void login(String uid, String pass) throws Exception {
driver.manage().timeouts().implicitlyWait(9, TimeUnit.SECONDS);
driver.get("http://www.drupal.org/user");
driver.findElement(By.id("edit-name")).sendKeys(uid);
driver.findElement(By.id("edit-pass")).sendKeys(pass);
driver.findElement(By.id("edit-submit")).click();
try{
driver.findElement(By.linkText("Logout")).click();
str="Pass";
}
catch(Exception e){
str="Fail";
}
}
@BeforeTest
public void beforeTest() {
driver=new FirefoxDriver();
/* System.setProperty("webdriver.chrome.driver","D:\\lib\\chromedriver.exe"); //--->chrome browser path
driver=new ChromeDriver();*/
driver.manage().window().maximize();
}
}