Parameterization in TestNg
Dataprovider
Annotation in TestNG
Dataprovider annotation is mainly used for parameterization
in Test Cases
We have a define a method under the data provide annotation,
here we pass test data
Data provider method return of 2 dimension object array
We can pass this data
returned by data provider in our test cases, function will execute in loop for
each row of returned 2 dimension array
Here is the example
package org.abc;
import
org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import
org.testng.annotations.DataProvider;
import
org.testng.annotations.Test;
public class Case1 {
@Test(dataProvider="Dp1")
public void TCase(String uname, String pass)
{
System.setProperty("webdriver.chrome.driver","C:\\Documents
and Settings\\Administrator\\My
Documents\\Downloads\\chromedriver_win32_2.1\\chromedriver.exe");
ChromeDriver f = new ChromeDriver();
f.get("http://mail.in.com");
f.findElementById("f_id").sendKeys(uname);
f.findElementById("f_pwd").sendKeys(pass);
f.findElementByClassName("signin");
}
@DataProvider(name="Dp1")
public Object[][]
DataRe()
{
Object arr[][]={{"unam1","pass1"},
{"uname2","pass2"},
{"uname3","pass3"}};
return(arr);
}
}
Subscribe to:
Post Comments
(
Atom
)
No comments :
Post a Comment